Numidia was the ancient kingdom of the Numidians in northwest Africa, initially comprising the territory that now makes up Algeria, but later expanding across what is today known as Tunisia and Libya. The polity was originally divided between the Massylii in the east and the Masaesyli in the west. During the Second Punic War, Masinissa, king of the Massylii, defeated Syphax of the Masaesyli to unify Numidia into the first Berber state in present-day Algeria. The kingdom began as a sovereign state and later alternated between being a Roman province and a Roman client state.