He then dispatched a force, but Sulaymān al-Mustaʿīn routed it.
Next he marched until he approached Córdoba. The Mahdī’s troops sallied out to face him, and Sulaymān engaged them; those who drowned in the ravine outnumbered those killed by the sword. It was a terrible battle in which many of the righteous—imams and muezzins alike—perished.
At daybreak the Mahdī produced before the people the caliph al-Muʾayyad bi-Allah, Hishām ibn al-Ḥakam, whose death he had earlier proclaimed. He seated him in public view while the chief judge called out:
“This is the Commander of the Faithful, and Muḥammad ibn Hishām ibn ʿAbd al-Jabbār is only his deputy.”
The Berbers retorted, “Son of Zakwān, yesterday you led his funeral prayer—today you raise him from the dead?!”
The people of Córdoba then went out to Sulaymān al-Mustaʿīn, who welcomed them graciously, while Muḥammad al-Mahdī slipped into hiding. Al-Mustaʿīn’s position was now secure; he entered the palace of government, and the people buried their dead—about twelve thousand in all.
The Mahdī stole away to Toledo, whose inhabitants rallied to him. He wrote to the Franks, promising them money, and a vast host gathered round him; this was the first time funds from the Andalusian public treasury were sent to the Franks. All the frontier garrisons still acknowledged his authority, so he advanced on Córdoba at the head of a mighty army. The two forces met at ʿAqabāt al-Baqar, a single post-stage from the city, and fought with extreme ferocity. Sulaymān al-Mustaʿīn was defeated, and the Mahdī again took Córdoba.
A few days later he marched out to fight the massed Berber forces, met them in the valley of Āruh, and suffered a humiliating rout: three thousand of his Frankish soldiers were slain and many others drowned. He returned to Córdoba, where the slaves rose against him, cut off his head, quartered his body, and thus Allah spared the people his evil on the eighth of Dhū al-Ḥijjah, 400 AH. He lived thirty-four years. (1)
Al-Ḥumaydī (2) says: “Al-Muʾayyad bi-Allah was reinstated as caliph at the close of the year four…”