أبو يزيد
Leaving Abu Ammar and his own son to govern Kairouan in his name, Abu Yazid moved to capture the final Fatimid stronghold, the coastal palace city of al-Mahdiya. On 2 November 944, he defeated and killed the Fatimid general Maysur, opening the path to the city. The first attack on the city, on 21 January 945, reached the palace mosque courtyard (), but was eventually pushed back. The city was placed under siege, which lasted until September 945, when Fatimid counterattacks forced Abu Yazid to retreat to Kairouan. There he abandoned the luxuries he had adopted and returned to his previous austere life, leading to a resurgence in Berber support for his cause. Seeking allies against the Fatimids, Abu Yazid also sent some Kairouan notables as envoys to the Spanish Umayyads. After this first embassy was well received, Abu Yazid sent his son Ayyub to pledge allegiance to the Umayyad caliph Abd al-Rahman III, who in turn promised to send support.