Masinissa, the son of the chieftain Gala of a Numidian tribal group, the Massylii, had been brought up in Carthage, an ally of his father.
At the start of the Second Punic War (218-201 BCE), Masinissa had fought for Carthage against Syphax, the King of the Masaesyli of western Numidia (present day Algeria), who had allied himself with the Romans.
Masinissa, then seventeen years old, had led an army of Numidian troops and Carthaginian auxiliaries against Syphax's army and won a decisive victory.
Numidia is of vital importance to Carthage, supplying both mercenaries and allied forces.
In addition to supplying the Numidian cavalry, Numidia operates as a buffer for vulnerable Carthage.
When Gaia dies in 206, his sons Masinissa and Oezalces quarrel about the inheritance, and Syphax—now an ally of Carthage—is able to conquer considerable parts of the eastern Numidian kingdom.
Meanwhile, with the Carthaginians having been driven from Spain, Masinissa concludes that Rome is winning the war against Carthage and therefore decides to defect to Rome, promising to assist Publius Scipio, later known as Scipio Africanus, in the invasion of Carthaginian territory in Africa.
This decision is aided by the move by Scipio to free Masinissa's nephew, Massiva, whom the Romans had captured when he had disobeyed his uncle and ridden into battle.
Having lost the alliance with Masinissa, Hasdrubal Barca starts to look for another ally and finds one in Syphax, who marries Sophonisba, the daughter of Hasdrubal Gisco, a celebrated beauty, who until the defection had been betrothed to Masinissa.
The Romans support Masinissa's claim to the Numidian throne against Syphax, who is nevertheless successful in driving Masinissa from power.