Hasanwayhids or Hasanuyid was a powerful Shia Kurdish dynasty reigning the western parts of Iran such as Iranian Azerbaijan and Zagros Mountains between Shahrizor and Khuzestan from c. 959 to 1015. The last Hasanwayhid ruler died in 1015 in Sarmadj, south of Bisotun, as the Seljuks began entering the region. Aishanid predecessors The Hasanwayhids were preceded in the region by the Aishanid or 'Ishaniya kurdish tribe. This particular group had ruled territories in the districts of Dinawar, Hamadan and Nahavand.Their emirs Ghanim and Windad (sons of a certain Ahmad) had usurped the rule from the Abbasid caliphate for fifty years, until their death in 960-961.The next generation of Aishani emirs couldn't keep the control of their family castles: Ghānim’s son Daysam was defeated by the Buyid armies, and Windād’s son ʿAbd al-Wahhāb, was taken prisoner by a rival Kurdish group, and handed to the first Hasanwayhid ruler, Hasanwayh. He was a maternal nephew of Ghanim and Windad, and he obtained the castles of their Aishani relatives. History The name of the dynasty was an eponym to their first ruler Hasanwayh ibn Husayn from the Barzikani tribe. A vassal of the Buyid dynasty, Hasanwayh supported them against the Samanids which enabled him in gaining some power. He would ultimately control much of Lorestan, Dinavar, Nahavand and Hamadan and was powerful to such degree in which the Buyids refrained from disturbing him. The influence of Hasanwayh reached Azerbaijan. After his death in 979, his son Badr ibn Hasanwayh became ruler and achieved notable gains including imposing order, developing a strong financial administration, building roads and markets in the mountains, securing the safety of pilgrims crossing his territory and striking coins. Like his father, he continued to pledge his allegiance to the Buyids. Badr ibn Hasanwayh was succeeded by his grandson Zahir in 1014 but only kept power for a year as he was expelled by Buyid Shams al-Dawla and shortly after killed. The Annazids took large parts of its western territory and became their immediate successors. The eastern parts were taken by the Buyids, while the Kakuyids took the southern portions. All of the formerly held Hasanwayhids territory was ultimately taken by Tughril. The Sarmaj Castle was built by the Hasanwayhids. Rulers Hasanwayh (961–979) Badr ibn Hasanwayh (979–1014) Zahir ibn Hilal ibn Badr (1013–1014) Hilal ibn Badr (1014) Zahir ibn Hilal ibn Badr (1014–1015) See also List of Kurdish dynasties and countries