The Zirid dynasty (الزيريون), Banu Ziri (بنو زيري), was a Sanhaja Berber dynasty from modern-day Algeria which ruled the central Maghreb from 972 to 1014 and Ifriqiya (eastern Maghreb) from 972 to 1148.
Descendants of Ziri ibn Manad, a military leader of the Fatimid Caliphate and the eponymous founder of the dynasty, the Zirids were emirs who ruled in the name of the Fatimids. The Zirids gradually established their autonomy in Ifriqiya through military conquest until officially breaking with the Fatimids in the mid-11th century. The rule of the Zirid emirs opened the way to a period in North African history where political power was held by Berber dynasties such as the Almoravid dynasty, Almohad Caliphate, Zayyanid dynasty, Marinid Sultanate and Hafsid dynasty.
Under Buluggin ibn Ziri the Zirids extended their control westwards and briefly occupied Fez and much of present-day Morocco after 980, but encountered resistance from the local Zenata Berbers who gave their allegiance to the Caliphate of Cordoba. To the east, Zirid control was extended over Tripolitania after 978 and as far as Ajdabiya (in present-day Libya). One member of the dynastic family, Zawi ibn Ziri, revolted and fled to al-Andalus, eventually founding the Taifa of Granada in 1013, after the collapse of the Caliphate of Cordoba. Another branch of the Zirids, the Hammadids, broke away from the main branch after various internal disputes and took control of the territories of the central Maghreb after 1015. The main branch of the Zirids, also called the Badisides, occupied only Ifriqiya between 1048 and 1148. They were based in Kairouan until 1057, when they moved the capital to Mahdia on the coast. The Zirids of Ifriqiya also intervened in Sicily during the 11th century, as the Kalbids, the dynasty who governed the island on behalf of the Fatimids, fell into disorder.
The Zirids of Granada surrendered to the Almoravids in 1090, but the Badicides and the Hammadids remained independent during this time.