Timur appointed Uzun Hasan's great-grandfather, Kara Yülük Osman, as a governor of Diyarbakır, with the cities of Erzincan, Mardin, Ruha (or Urfa), and Sivas. Later, Persia was divided between two Timurid rulers, Jahan Shah of Kara Koyunlu (the Black Sheep Turkoman) and Uzun Hasan. After twenty years of fighting, Uzun Hasan eventually defeated Jahan Shah in a battle near the sanjak of Çapakçur in present-day eastern Turkey on October 30 (or November 11), 1467. Upon the defeat of the latter, another Timurid ruler, Abu Sa'id Mirza, answered Jahan Shah's son's request for aid, taking much of Jahan Shah's former land and going to war with Uzun Hasan despite the latter's offers of peace. Uzun Hasan then ambushed and captured Abu Sa'id at the Battle of Qarabagh, whereupon he was executed by Yadgar Muhammad Mirza, a rival.