under the banner of Ibadi Islam. The Ibadi had been fighting Umayyad rule in the East, and many Berbers were attracted by the sect's seemingly egalitarian precepts. After the revolt, Ibadis established a number of theocratic tribal kingdoms, most of which had short and troubled histories. But others, such as Sijilmasa and Tlemcen, which straddled the principal trade routes, proved more viable and prospered. In 750, the Abbasids, who succeeded the Umayyads as Muslim rulers, moved the caliphate to Baghdad and reestablished caliphal authority in Ifriqiya, appointing Ibrahim ibn al Aghlab as governor in Kairouan. Though nominally serving at the caliph's pleasure, Al Aghlab and his successors, the Aghlabids, ruled independently until 909, presiding over a court that became a center of learning and culture. Just to the west of Aghlabid lands, Abd ar Rahman ibn Rustam ruled most of the central Maghreb from Tahert, south-west of Algiers. The rulers of the Rustamid imamate (761–909), each an Ibadi imam, were elected by leading citizens. The imams gained a reputation for honesty, piety, and justice. The court at Tahert was noted for its support of scholarship in mathematics, astronomy, astrology, theology, and law. The Rustamid imams failed, by choice or by neglect, to organize a reliable standing army. This important factor, accompanied by the dynasty's eventual collapse into decadence, opened the way for Tahert's demise under the assault of the Fatimids. Mahdia was founded by the Fatimids under the Caliph Abdallah al-Mahdi in 921, and made the capital city of Ifriqiya by caliph Abdallah El Fatimi. It was chosen as the capital because of its proximity to the sea, and the promontory on which an important military settlement had been since the time of the Phoenicians. In al-Andalus under the Umayyad governors The Muslims who invaded the Iberian Peninsula in 711 were mainly Berbers, and were led by a Berber, Tariq ibn Ziyad, under the suzerainty of the Arab Caliph of Damascus Abd al-Malik ibn Marwan and his North African Viceroy, Musa ibn Nusayr. Due to subsequent antagonism between Arabs and Berbers, and due to the fact that most of the histories of al-Andalus were written from an Arab perspective, the Berber role is understated in the available sources. The biographical dictionary of Ibn Khallikan preserves the record of the Berber predominance in the invasion of 711, in the entry on Tariq ibn Ziyad. A second mixed army of Arabs and