During the caliphate of al-Mahdi (r. 775–785) Ali served as governor of the Yemen (777–778)[2] and once or twice as governor of the Jazirah and Qinnasrin (c. 782 – c. 785).[3] While in the latter position, he reportedly relocated the markets of Raqqa to a more central location between that city and al-Rafiqah,[4] and was instructed by al-Mahdi to rebuild the frontier town of Hadath after its sacking at the hands of the Byzantines.[5] Following the collapse of a truce with the Byzantines in 785, he dispatched a cavalry force under Yazid ibn Badr ibn al-Battal on a raid which resulted in the acquisition of some spoils.[6]