Numidia was an ancient Berber kingdom in modern-day Algeria and a smaller part of western Tunisia in North Africa. Numidia is first recorded in history as divided between two related tribal federations, the Maesulians in the east, and Masaesyli in the west. The Masaesylian king Massinissa allied with Rome during the Second Punic War, and, with Roman assistance, conquered the Maesulians, forming Numidia into one kingdom. The loss of their Maesulian allies deprived Carthage of its best source of cavalry, the Berber tribesmen making superb light horsemen, and contributed greatly to Carthage's great general Hannibal's loss at the Battle of Zama in 202 B.C., ending the war in Carthaginian defeat. Numidia profited from the alliance with Rome, annexing a number of Carthaginian cities in north Africa in the aftermath of the Second Punic War, and providing the instigation of the Third Punic War, ending in Carthage's utter destruction, by ongoing conquest of other Carthaginian towns and cities.