Ahmad was the son of Isma'il and a grandson of Ali ibn Abdallah ibn al-Abbas, and was a first cousin of the first two Abbasid caliphs al-Saffah (r. 750–754) and al-Mansur (r. 754–775).[2] During the caliphate of al-Mahdi (r. 775–785) he was appointed to the governorship of Mosul (781–783/5)[3] and later became al-Mahdi's final governor of Mecca.[4] Under Harun al-Rashid (r. 786–809) he was again appointed to Mecca[5] and also served as governor of the Yemen (c. 797).[6][7]