Throughout much of the 10th century, authority over the western Maghreb was contested between the
Fatimids (based in
Ifriqiya) and the
Umayyads of Córdoba (based in
al-Andalus), each assisted by local allies. The Umayyads held two garrisoned forts along the coast,
Ceuta and
Mellila, while their main allies in the interior were
Zenata tribes. Between 958 and 960, the Fatimid general
Jawhar succeeded in submitting most of the region to Fatimid authority, aided by
Ziri ibn Manad, another Fatimid commander from
Ashir. In 969, Jawhar
conquered Egypt and in 973 the Fatimid caliph
al-Mu'izz moved his court to
Cairo, the new Fatimid capital. Before leaving, he appointed
Buluggin ibn Ziri, the son and successor of Zirid ibn Manad, as his
viceroy in the Maghreb. This spawned the
Zirid dynasty which ruled the region officially in the name of the Fatimid caliphs. The Umayyads in North Africa were placed under the command of Ja'far ibn Ali ibn Hamdun and his brother Yahya, though by 978 Ja'far had returned to al-Andalus, leaving Yahya in sole command. The authority of the Umayyad commanders was recognized by the main Zenata factions, including the chiefs of the
Maghrawa,
Ziri ibn Atiyya and his brother Muqatil, the chief of the
Banu Ifran, Yaddu ibn Ya'la, and the
Miknasa. Towards 978, another powerful Maghrawa chief and Umayyad vassal, Hazrun ibn Fulful ibn Hazar al-Zanati, captured Sijilmasa from the
Ibadis and executed their
Midrarid caliph, bringing the city under Umayyad authority for the first time. == Campaign ==