re established in Numidia, behind the coastal areas controlled by Carthage. West of Numidia lay Mauretania, which extended across the Moulouya River in modern day Morocco to the Atlantic Ocean. The high point of Berber civilization, unequaled until the coming of the Almohads and Almoravids more than a millennium later, was reached during the reign of Massinissa in the second century BC.
After Masinissa's death in 148 BC, the Berber kingdoms were divided and reunited several times. Massinissa's line survived until 24 AD, when the remaining Berber territory was annexed to the Roman Empire for 2 centuries.
Arrival of Islam
When Muslim Arabs arrived in Algeria in the mid-7th century, a large number of locals converted to the new faith. After the fall of the Umayyad Arab Dynasty in 751, numerous local Berber dynasties emerged. Amongst those dynasties were the Aghlabids, Almohads, Abdalwadid, Zirids, Rustamids, Hammadids, Almoravids and the Fatimids. converted the Berber Kutama of the Lesser Kabylia to its cause, the Shia Fatimids overthrew the Rustamids, and conquered Egypt, leaving Algeria and Tunisia to their Zirid vassals. When the latter rebelled, the Shia Fatimids sent in the Banu Hilal and Banu Sulaym Arabian tribes who unexpectedly defeated the Zirids.
The Berber people controlled much of the Maghreb region throughout the Middle Ages. The Berbers were made up of several tribes. The two main branches were the Botr and Barnès tribes, who were themselves divided into tribes, and again into sub-tribes. Each region of the Maghreb contained several tribes (for example, Sanhadja, Houaras, Zenata, Masmouda, Kutama, Awarba, and Berghwata). All these tribes were independent and made territorial decisions.
Several Berber dynasties emerged during the Middle Ages in Maghreb, Sudan, Andalusia, Italy, Mali, Niger, Senegal, Egypt, and other nearby lands. Ibn Khaldun provides a table summarizing the Zirid, Banu Ifran,