The Fitna of al-Andalus (1009–1031) was a period of instability and civil war that preceded the ultimate collapse of the Caliphate of Córdoba. It began in the year 1009 with a coup d'état which led to the assassination of Abd al-Rahman Sanchuelo, the son of Almanzor, the deposition of the Caliph Hisham II al-Hakam, and the rise to power of Muhammad II of Córdoba, great-grandson of Abd-ar-Rahman III. The conflict would eventually divide all of Al-Andalus into a series of Taifa Kingdoms. The Fitna finally ended with the definitive abolition of the Cordoban Caliphate in 1031, although various successor kingdoms would continue to claim the caliphate for themselves. In addition to the political turmoil, large purges were also carried out by Almanzor throughout his territories. The added pressures of financial collapse were present due to the large tax burden placed on the populace to finance the continuous war.
Throughout the conflict, various Muslim kingdoms were aided by the Christian kingdoms to the north, both in an official capacity and by mercenary Christian soldiers. Cordoba and its suburbs were repeatedly looted during the war, destroying many iconic monuments such as the Alcázar de los Reyes Cristianos and the Medina Azahara. The capital was temporarily moved to Málaga. In a little less than twenty years, 10 different caliphates emerged as successor states to the Caliphate of Cordoba (amongst them was a restored kingdom under Hisham II). Three of these successor kingdoms formed a dynastic succession line known as the Hammudid Dynasty.
Up until the death of Al-Hakam II in the year 976, the Caliphate of Córdoba was a powerful state, both respected and feared by the Christian kingdoms to the north. After his death, his son, Hisham II al-Hakam was still a child. As a result, the vizier, Almanzor was able to easily manoeuver and seize power, usurping the Umayyad Caliphate claim and turning the Caliph into a mere puppet. The strength of the Caliphate lay in the unity of different Muslim groups, following the terrible civil wars that had drained the Emirate. To be assured in the conservation of his power, Almanzor favored the Berbers over the other groups. Similar accommodation in the pecking order was transferred to Almanzor's son Abd al-Malik al-Muzaffar when he succeeded his father to the throne. To exacerbate the situation, government security was further undermined by various plots as rival groups vied for power. Abd al-Malik died in 1008, leaving his brother, Abd al-Rahman Sanchuelo in power. Sanchuelo was able to convince Hisham II to name him the rightful heir to the Caliphate. This marked the last straw for the remaining Umayyad members who proceeded to launch a full scale coup d'état and revolt against the state.