Hamdanid dynasty
The city was part of the Umayyad Caliphate and then the Abbasid Caliphate, but then came under more local rule until its recovery in 899 by forces loyal to the caliph al-Mu'tadid () before falling under the sway of first the Hamdanid dynasty and then the Buyid dynasty, followed by a period of control by the Marwanids. The city was taken by the Seljuks in 1085 and by the Ayyubids in 1183. Ayyubid control lasted until the Mongol invasions of Anatolia, and the Mongol capture of the city in 1260. Between the Mongol occupation and conquest by the Safavid dynasty of Iran, the Kara Koyunlu and Aq Qoyunlu – two Turkoman confederations – were in control of the city in succession. Diyarbakır was conquered by the Ottoman Empire in 1514 by Bıyıklı Mehmed Pasha, in the reign of the sultan Selim I (). Mohammad Khan Ustajlu, the Safavid governor of Diyarbakir, was evicted from the city and killed in the following Battle of Chaldiran in 1514.