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.
He next caused a circular letter, commanding all Maghribins to refuse obedience to the caliph, to be read from the pulpit throughout the whole extent of the Maghrib (western North Africa).
Baths, the Zeirid ruler of the Maghrib, made himself independent, and substituted in prayer the name of the Abbasid caliph for that of Mostansir.