Subsequently it came under the control of Turkmen dynasties like the Āq Qoyunlū and Qara Qoyunlū and then of local khanates like those of Qara Bāḡ and Naḵǰavān which formed a buffer region between the Ottomans and Safavids.