After the fall of the Caliphate of Córdoba in 1031, Al-Andalus fragmented into a collection of small, independent Taifa emirates.
In response, the prominent citizens appointed Abū 'l Ḥazm Jahwar bin Muḥammad, a notable sheikh from the Banu Jwahar, as their leader.
Abū 'l Ḥazm soon established a republican system of government in Córdoba, creating a council of ministers and judicial authorities that he consulted before making political decisions.
This internal conflict weakened Córdoba, prompting 'Abd al-Malik to seek an alliance with the Emir of Seville, Abbad II al-Mu'tadid.
In 1070, after defeating the Toledan army, Al Mutamid captured Córdoba and deposed 'Abd al-Malik, who was first imprisoned and then exiled to the island of Saltés.