when they encountered a band of Kutama cavalry, they panicked and retreated to Baghaya, where they took up a defensive position. With its 1172-meter-long stone walls with 25 towers, built in 539 under Justinian's governor Solomon and still partially standing today, Baghaya was considered practically impenetrable. However, in May or June of 907, some local notables who had secretly aligned themselves with Abu Abdallah opened the city's gates to his forces, and they took the city without a fight. The fall of such an important stronghold as Baghaya unleashed panic at the Aghlabid court in Raqqada. Ziyadat Allah's vizier, Ibn al-Sa'igh, advised fleeing to Egypt, and Ziyadat Allah quickly bought five hundred camels in preparation. However, he soon changed his mind, and had an official proclamation read from every mosque in Aghlabid Ifriqiya – propaganda. This speech downplayed the Aghlabids' losses in battle, saying that Ziyadat Allah would lead an army in person to defeat the "corrupters of religion". At the same time, a letter circulated, supposedly from the Abbasid caliph al-Muktafi and promising to send aid, while enjoining the people of Ifriqiya to support Ziyadat Allah "against the enemies of God". At the same time, Ziyadat Allah raised a volunteer army, personally handing out gold pieces to volunteers while seated on his throne under the parade pavilion (qubbat al-arḍ), although many simply left after being paid. Ziyadat Allah, however, did not take command of this army, which mustered at al-Aribus at the end of October 907. That task was left to the prince Ibrahim ibn Abi al-Aghlab, who was ordered to remain in al-Aribus, on the northern Roman road, while Ziyadat Allah headed back to Tunis. They expected Abu Abdallah to approach via this route when they inevitably attacked Kairouan. Abu Abdallah, however, came from the south, capturing several cities in early 908 and forcing the Aghlabids under Ibrahim to march south. The two armies met at Dar Madyan, a place which was probably between Sbeitla and Kasserine, and fought an indecisive battle. Ibrahim returned to al-Aribus, while Abu Abdallah and the Kutama continued eastward, capturing Qastiliya (the region around the Chott el-Djerid) before withdrawing. The decisive final battle took place at al-Aribus on Saturday, 18 March 909. The fighting lasted until the asr prayer (late afternoon), when a unit of 575 Kutama warriors, having circled around the battlefield in a deep streambed, attacked the Aghlabid army in the