Hasanwayhids or Hasanuyid was a powerful Shia Kurdish dynasty reigning the western parts of Zagros Mountains between Shahrizor and Khuzestan from c. 959 to 1014 during the Abbasid decline. The last Hasanwayhid ruler died in 1014 in Sarmadj, south of Bisotun, as the Seljuks began entering the region.
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.