The Hammudid dynasty was a BerberMuslim dynasty that briefly ruled the Caliphate of Córdoba and the taifas of Málaga and Algeciras.
The dynasty is named after their ancestor, Hammud, a descendant of Idris ibn Abdallah, whose ancestors had established themselves among the Berber tribes of northern Morocco. When Sulayman ibn al-Hakam carved out Andalusian land for his Berber allies, two members of the Hammudid family were given the gouvernership of Algeciras, Ceuta and Tangier. The Hammudids thus gained control of the traffic across the Straits of Gibraltar, suddenly becoming a powerful force. Claiming to act on behalf of the dethroned Hicham II, the Hammudi gouvernor of Ceuta Ali ibn Hammud al-Nasir marched upon Córdoba in the year 1016, where he was crowned Caliph.
In the aftermath of the fall of Córdoba and the following civil conflicts, the Hammudids were part of the shi'at al-Barbariya (the Berber faction), while still being able to claim Chorfa descendence. Thus their Berber heritage gave them the nominal support of the Berber emirs (and that of a large North-African army), while their Chorfa heritage made a Caliphal claim acceptable to many in the Arab and Andalusian elite. The last Hammudid Caliph was dethroned by the Zirids of Granada, who had previously been the Hammudids' most important supporters. The Hammudi family was then forced to settle in Ceuta, Morocco.