 The defeat at Ardabil was a major shock to the Muslims , who for the first time faced an enemy penetrating so deep within the borders of the Caliphate , and Caliph Hisham appointed the veteran military leader Sa 'id ibn Amr al @-@ Harashi to take command against the Khazars . Although the forces he could muster immediately ( including refugees from Ardabil who had to be paid ten gold dinars to be persuaded to fight ) were small , Sa 'id managed to recover Akhlat on Lake Van . From there he moved northeast to Bardha 'a and south again to relieve the siege of Warthan . Near <unk> Sa 'id came upon a 10 @,@ 000 @-@ strong Khazar army , which he defeated , killing most of the Khazars , and rescuing the prisoners they had with them . The surviving Khazars fled north , with Sa 'id in pursuit . Despite this success , Sa 'id was relieved of his command in early 731 and even imprisoned for a while as a result of the jealousy of Maslama , whom Hisham re @-@ appointed as governor of Armenia and Adharbayjan . Maslama came to the Caucasus with many Jaziran troops and took to the offensive . He restored the provinces of Albania to Muslim allegiance through exemplary punishment of those who resisted his advance , and reached Derbent , where he found a Khazar garrison . Bypassing the fortress , Maslama advanced north , following the retreating Khazars . Although the details of this campaign in the sources may be confused with that of 728 , it appears that he took <unk> , Balanjar , and Samandar before being forced to retreat again after a confrontation with the khagan himself , in which Barjik was reportedly killed and the khagan wounded . The Khazars shadowed Maslama 's march south and attacked him near Derbent , but the Arab army dug a trench and defeated them . Taking advantage of his victory , Maslama evicted the Khazars from Derbent by poisoning their water supply and re @-@ founded the city as a military colony , garrisoning it with 24 @,@ 000 mostly Syrian troops . After that he returned with the rest of his army ( mostly the favoured Jaziran and <unk> contingents ) south of the Caucasus for the winter , while the Khazars re @-@ occupied their abandoned towns . Despite the capture of Derbent , Maslama 's record was apparently unsatisfactory for Hisham , who replaced his brother in March 732 with Marwan ibn Muhammad , who would later reign as the last Umayyad caliph in 744 – 750 . 
