Hasanwayhids

Hasanawayhid or Hasanuyid (, ) was a Kurdish Muslim principality from 961 to 1047, centered at Dinavar (northeast of present-day Kermanshah). The principality ruled western Iran and upper Mesopotamia. The founder of the dynasty was Hasanwayh from the Kurdish tribe of Barzikani. He managed to successfully resist Sahlan ibn Musafir, the Buyid governor of Hamadan, and the Buyid vizier, Ibn al-Amid. In 970 he reached a compromise with Amid's successor which guaranteed his autonomy. Hasanwayh died in 979 at Sarmaj, located in the south of Bisitun.
,After Hasanwayh's death, conflict broke out among several of his sons. The intervention of Buyid Mu'ayyad al-Dawla of Ray led to the defeat of Fakhr al-Dawla, one of Hasanwayh's sons. Then another heir, Badr ibn Hasanwayh (also known as Abu'l-Najm and Nasir al-Dawla), was installed as the leader of Bazikani Kurds, and the principality became a vassal of the Buyids. Badr expanded Hasanwayhid control to Shapur-Khwast, Dinawar, Nahavand, Asadabad, Borujerd, Ahwaz, Ilam, Kermanshah, Hulwan, Kirkuk and Sharazor.
Around 1006, the principality came into conflict with the Annazids to the west. Badr finally died in a minor battle in 1014. The principality was conquered by Abul-Shawk, the Annazid ruler. However the princely family continued to rule their stronghold at Sarmaj until the Seljuk Ibrahim Inal entered their territory in 1047.