For the history of Spain and the Maghrib the writings of Ibn al-Khatib (d.
Fi Aiyam el Maghrib, Eec. (cir.
In 969 the country was conquered by Jauhar for the Fatimite caliph Moizz, who transferred his capital from Mahdia in the Maghrib to Cairo.
During his absence his son Abbs revolted in Egypt; on the news of his fathers return he fled to Barca, whence he endeavoured to conquer the Aghlabite dominions in the Maghrib; he was, however, defeated by the Aghlabite ruler, and returned to Barca, where he was again defeated by his fathers forces and taken prisoner.
Badis, the 4th ruler of the dependent Zeirid dynasty which had ruled in the Maghrib since the migration of the F~imite Moizz to Egypt, definitely abjured his allegiance (1049) and returned to Sunnite principles and subjection to the Bagdad caliphate.