Zirid dynasty
In 987 and 989, al-Mansur ibn Buluggin, the emir of the Berber Zirid dynasty, appointed his uncle Hammad ibn Buluggin as governor of Ashir and western Zirid lands. Hammad subsequently defended the territory against Zenata incursions and was granted additional lands by al-Mansur's successor Badis ibn Mansur. In 1007 and 1008, forces under Hammad left Ashir and built a new citadel-capital, Qalaat Beni Hammad (also called "Al Qal'a of Beni Hammad"), in M'Sila Province in the Hodna Mountains; a thriving city sprung up around the fortress.