Year 240 BC was a year of the pre-Julian Roman calendar. At the time it was known as the Year of the Consulship of Centho and Tuditanus (or, less frequently, year 514 Ab urbe condita). The denomination 240 BC for this year has been used since the early medieval period, when the Anno Dominicalendar era became the prevalent method in Europe for naming years.

Two of Carthage's mercenary commanders – Spendius and Mathos – convince the Libyan conscripts in the mercenary army, that is currently occupying the Carthaginian city of Tunis, to accept their leadership. They persuade the native Libyans that Carthage will take revenge against them for their part in the conflict once the foreign mercenaries are paid and sent home. They then convince the combined mercenary armies to revolt against Carthage and convince the various native Libyan towns and cities to back the revolt. Spendius and Mathos then take the Carthaginian commander Gesco as a hostage. What has started as an argument over pay owed to soldiers by the Carthaginian Government, explodes into a full-scale revolt, known as the Mercenary War.

The Libyan forces loyal to the mercenaries besiege the towns of Utica and Hippacritae, which refuse to defect to the mercenaries.

Carthage decides to give Hamilcar Barca joint command with Hanno the Great. Hamilcar Barca is able to end the siege of Utica by the mercenaries. He is then placed in complete command of the Carthaginian forces and defeats the mercenaries in the Battle of the Bagradas River.

After the Numidian mercenary leader Narawas defects to Hamilcar Barca, Numidian reinforcements (about 2,000 men) help him defeat the mercenaries again. Hamilcar pardons his captured prisoners, accepting into his army anyone who will fight for Carthage, and exiling anyone who will not.