Around 1069, Badr al-Jamali, then Fatimid governor (wali) of al-Sham, sent messengers to the Turkomans living in Anatolia, asking them to fight against invading Bedouin tribes in his region.
[1] Atsiz, commander of the Turkoman Nawaki tribe[2] or group also known as Nawakiyya, arrived in Syria after that and seems to have fought for some time with the Fatimids against the Bedouins.
In 1070, with the civil war in the Caliphate still raging, disputes about the financial compensation seem to have led some Turkoman to side with the Bedouin and seek to establish their own principality.
[2][4] In 1077, he broke his promise of amān, or quarter, given to the rebels, and after they opened the gates, his troops slaughtered an estimated 3,000 of them, including those who had taken shelter in the Al-Aqsa Mosque and only sparing those inside the Dome of the Rock.
[1] Atsiz's principality represents one of the many Turkmen state foundations on the periphery of the Seljuk empire, such as the emirates of Rum, of Izmir or of the Danishmendids that sprung up during the same period.