The Arab–Khazar wars were a result of the attempts of the Umayyad Caliphate to secure control of Transcaucasia and the North Caucasus, where the Khazars were already established. The first Arab invasion, in the 640s and early 650s, ended with the defeat of an Arab force led by Abd ar-Rahman ibn Rabiah outside the Khazar town of Balanjar. Hostilities broke out again with the Caliphate in the 710s, with raids back and forth across the Caucasus Mountains. Led by the distinguished generals al-Jarrah ibn Abdallah and Maslama ibn Abd al-Malik, the Arabs were able to capture Derbent and even the southern Khazar capital of Balanjar, but these successes had little impact on the nomadic Khazars, who continued to launch devastating raids deep into Transcaucasia. In one such raid in 730, the Khazars inflicted a major defeat on the Umayyad forces at the Battle of Ardabil, killing al-Jarrah, but were in turn defeated the next year and pushed back north. Maslama then recovered Derbent, which became a major Arab military outpost and colony, before being replaced by Marwan ibn Muhammad (the future caliph Marwan II) in 732. A period of relatively localized warfare followed until 737, when Marwan led north a massive expedition that reached the Khazar capital Atil on the Volga. After securing some form of submission by the "khagan", the Arabs withdrew.