From 759, the
Abbasid Caliphate set out to recover the Maghreb for the empire. Once the caliph,
Abu Ja'far al-Mansur, has dealt with his internal problems in the
Mashriq, he shifted his focus to the
Maghreb. He appointed
Muhammad ibn al-Ash'ath al-Khuza'i as governor of Egypt and the Maghreb, and ordered him to suppress the Kharijite rebellion in Ifriqiya. Ibn al-Ash'ath initially sent two armies which were both defeated by the Ibadites. Ibn al-Ash'ath then took command of an army and defeated the Ibadites in the battle of
Tawargha (near
Misrata,
Libya), killing the Ibadi Imam
Abu al-Khattab al-Ma'afiri and many of his followers. Several consecutive Berber armies were defeated and forced to retreat to the mountains, and al-Abu al-Khattab's head was sent to
Baghdad in triumph. Ibn al-Ash'ath then marched on Ifriqiya, capturing Kairouan in 761 where he forced the governor,
Abd al-Rahman ibn Rustum, to flee to the mountains located south of
Oran. Rustum fled westwards and established a new capital at
Tahert (present-day
Algeria). This campaign brought an end to the political domination of the Ibadites in Ifriqiya and established Abbasid direct authority there. The
Zab in eastern Algeria constituted the western limit of the area held by the Abbasid governors, where the Abbasids had an important military base at
Tubna. To the west of this territory were the
Rustamids,
Midrarids and
Idrisids. == Aftermath ==