Arab – Khazar wars The Arab – Khazar wars were a series of conflicts , usually grouped into the First Arab – Khazar War ( с . 642 / 652 ) and Second Arab – Khazar War ( c . 722 - 737 ) , fought between the armies of the Khazar Khaganate and the Umayyad Caliphate ( as well as its Abbasid successor ) and their respective vassals . The Arab – Khazar wars came about as the Khazars confronted the efforts of the Umayyad Caliphate to expand its control over and beyond the Caucasus . The first war was fought in the 640s and early 650s and 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 but few decisive battles . The Khazars , led by a prince named Barjik , invaded northwestern Iran and defeated the Umayyad forces at Ardabil in 730 , killing the Arab governor al - Jarrah al - Hakami and briefly occupying the town . They were defeated the next year at Mosul , where Barjik was killed . Arab armies led first by the Arab prince Maslama ibn Abd al - Malik and then by Marwan ibn Muhammad ( later Caliph Marwan II ) poured across the Caucasus and eventually ( in 737 ) defeated a Khazar army led by Hazer Tarkhan , briefly occupying Atil itself . The instability of the Umayyad regime made a permanent occupation impossible ; the Arab armies withdrew and Khazar independence was re - asserted . The last major battle between Khazar and Caliphate forces took place in 799 / 800 , when a Khazar army invaded Azerbaijan and Arran , and was driven back by the local governor , Yazid ibn Mazyad al - Shaybani . Low - intensity warfare continued thereafter in the region between the Khazars and the local Muslim principalities of the North Caucasus , until the collapse of the Khazar state in the late 10th century , but the great wars of the 8th century were not repeated . Background and strategic motives . The Arab – Khazar wars were part of a long series of military conflicts between the nomadic peoples of the Pontic - Caspian steppe and the more settled regions south of the Caucasus range , dating back to Antiquity . The two great passes over the Caucasus , the Darial Pass ( " Alan Gates " ) in the centre and the Pass of Derbent ( " Caspian Gates " ) had been used as invasion routes since Classical times , and their defence against the northern barbarian hordes came to be regarded as one of the chief duties of imperial regimes to the south . Thus the shahs of the Sassanid Empire , from Peroz I ( r . 457 – 484 ) to Khosrau I ( r . 531 – 579 ) , built a long line of fortifications from the Caucasus to the Caspian Sea . Derbent itself , which would feature prominently in the Arab – Khazar conflict , was built by the Persians in the early 6th century as a strategic choke - point and gateway ( its name in Persian , " Dar - band " , means " Knot of the Gates " ) between the north and south . This is reflected in the popular belief among Middle Eastern cultures that Alexander the Great had with divine assistance barred the Caucasus against the hordes of " Gog and Magog " , an echo of invasions by the Scythians and the Huns . Eventually , the Khazars would take their place , and early medieval writers came to identify the Khazars with Gog and Magog . Since the nascent Caliphate regarded itself as the heir of the Sassanid ( and to a lesser extent , Byzantine ) tradition and " civilizational consciousness " , the Arab caliphs also adopted the notion that it was their duty " to protect the settled , i . e . the civilized world from the northern barbarian " ( G . Mako ) . To this imperative was added the Muslim concept of division of the world into the " House of Islam " ( " Dar al - Islam " ) and the " House of War " ( " Dar al - Harb " ) , to which the pagan Turkic nomads were consigned . Consequently the eastern Caucasus range also became the main theatre of the Arab – Khazar conflict , with the Arab armies aiming to gain control of Derbent ( known in Arabic as Bab al - Abwab , " Gate of Gates " ) and the Khazar cities of Balanjar and Samandar , whose location has yet to be established with certainty . Both of the latter are referred to as Khazar capitals by different Arab writers , and may have functioned as winter and summer capitals respectively . It was only later , under the impact of the Arab attacks , that the Khazars moved their capital further north , to Atil on the mouths of the Volga . To an extent , the Arab – Khazar wars were also linked to the struggle of the Caliphate against the Byzantine Empire along the eastern fringes of Asia Minor , a theatre of war which adjoined the Caucasus . The Byzantine emperors pursued close relations with the Khazars , which amounted to a virtual alliance for most of the period in question , including such exceptional acts as the marriage of emperor Justinian II to a Khazar princess in 705 . The possibility of the Khazars linking up with the Byzantines through Armenia was a grave threat to the Caliphate , especially given its proximity to the Umayyad metropolitan province of Syria . This did not materialize , and Armenia was left largely quiet , with the Umayyads granting it wide - ranging autonomy and the Byzantines likewise refraining from active campaigning there . Although some Byzantinists , notably Dimitri Obolensky , suggested that the Arab – Khazar wars were motivated by a Muslim desire to outflank the Byzantine defences from the north , this idea is not borne out by the limited nature of the conflict before until the 720s . It is more probable that the Byzantines encouraged the Khazars to attack the Caliphate to relieve the mounting pressure on their own eastern frontier in the early 8th century , as indeed they profited considerably from the diversion of the Muslim armies northwards in the 720s and 730s , resulting in another marriage alliance , between the future emperor Constantine V ( r . 741 – 775 ) and the Khazar princess Tzitzak in 733 . The issue of control over the northern branch of the Silk Road by the Caliphate has been suggested as a further motive for the conflict , but G . Mako disputes this claim by pointing out that warfare declined at precisely the period of the greatest expansion of traffic along the Silk Road , i . e . after the middle of the 8th century . First conflicts : the First Arab – Khazar War and aftermath . The Khazars themselves first campaigned in the Caucasus during the Byzantine – Sassanid War of 602 – 628 , as a subject of the Western Turkic Khaganate . The Turks sacked Derbent and joined the Byzantines in their siege of Tiflis . Their contribution proved decisive for the eventual Byzantine victory in the war . For a few years afterwards , until c . 632 , the Khazars exercised some control over Iberia and Albania – Azerbaijan . The Khazars and the Arabs came into conflict as a result of the first phase of Muslim expansion : by 640 the Arabs had reached Armenia , and in 642 , they launched their first raid across the Caucasus under Abd ar - Rahman ibn Rabiah . In 645 / 6 , the Arabs defeated a Byzantine army in Armenia , reinforced with Khazar and Alan contingents . It was followed by an attempt in 651 / 652 to advance onto the Khazar capital , Balanjar , but the Arabs were heavily defeated in battle before the city , resulting in the death of Abd ar - Rahman ' s brother Salman and 4 , 000 Muslim troops . Three years later , the Khazars repelled a retaliatory campaign under Habib ibn Maslama . Due to the outbreak of the First Muslim Civil War and the Arab priorities on other fronts , the Muslims refrained from repeating an attack on the Khazars until the early 8th century . The Khazars , on their part , only launched a few raids into the Transcaucasia n principalities that were loosely under Muslim dominion : in 661 / 662 , they launched a raid into Caucasian Albania but were defeated by the local prince ; in 683 / 685 ( also a time of civil war in the Muslim world ) , a large - scale raid across Transcaucasia was more successful , capturing much booty and many prisoners . Climax : the Second Arab – Khazar War . Relations between the two powers remained relatively quiet until the early years of the 8th century , by which time the stage for the new round of conflicts was set . Byzantine political authority had been marginalized in the Caucasus , and the Caliphate tightened its grip on Armenia after the suppression of a large - scale rebellion in 705 . With Armenia annexed into the Caliphate , the Arabs and the Khazars faced each other for control of the Caucasus . Only the western parts of Transcaucasia , comprising modern Georgia , remained free from direct control by either of the two rival powers . War broke out in 713 / 714 , when the Umayyad general Maslama , a son of the Caliph Abd al - Malik ( r . 685 – 705 ) , conquered Derbent . Maslama then drove deeper into Khazar territory , trying , without success , to subdue the " Huns " living north of the Caucasus . The Khazars opposed him under the general Alp ' , but also launched raids to the south into Albania in response . In 717 , the Khazars raided in force into Iranian Azerbaijan , but they were driven back by the Arabs under Hatin ibn al - Nu ' man . Escalation of the conflict . In 721 / 722 , the main phase of the war began . In the winter of this year , 30 , 000 Khazars launched an invasion of Armenia and inflicted a crushing defeat on the mostly Syrian army of the local governor Mi ' laq ibn Saffar al - Bahrani at Marj al - Hijara in February / March 722 . In response , Caliph Yazid II ( r . 720 – 724 ) sent one of his most celebrated generals , al - Jarrah ibn Abdallah al - Hakami , with 25 , 000 Syrian troops north . Al - Jarrah was swiftly successful in driving the Khazars back across the Caucasus , recovered Derbent and even advanced on Balanjar . The Khazars tried to defend their capital by ringing the citadel with a laager of wagons , but the Arabs broke it apart and stormed the city on 21 August 722 ( or 723 ) . Most of Balanjar ' s inhabitants were killed or enslaved , but a few managed to flee north . Despite their success , however , the Arabs had not yet defeated the main Khazar army , which like all nomad forces was not dependent on cities for supplies . The threat of the Khazar army forced the Arabs to abandon any attempts on capturing Samandar as well , and to retreat to Warthan south of the Caucasus . The sources are obscure on al - Jarrah ' s activity in 723 , but he seems to have led another campaign north ( which may indeed be the Balanjar campaign ) . In response , the Khazars raided south of the Caucasus , but in February 724 , al - Jarrah inflicted a crushing defeat on them in a battle between the rivers Cyrus and Araxes that lasted for days . Al - Jarrah followed up his success by capturing Tiflis and bringing Caucasian Iberia and the lands of the Alans under Muslim suzerainty , becoming the first Muslim commander to campaign through the Darial Pass . This secured the Muslim ' s own flank against a possible Khazar attack through the Darial , while conversely it gave the Muslim army a second invasion route into Khazar territory . In 725 , the new Caliph , Hisham ibn Abd al - Malik ( r . 724 – 743 ) replaced al - Jarrah with his own brother Maslama , who already commanded the Jazira , possibly for reasons of balancing the provincial appointments among the various tribal groups . For the time being , however , Maslama remained in the Jazira and was more concerned with operations against the Byzantines . In his place , he sent al - Harith ibn Amr al - Ta ' i to the Caucasus front . In 725 , al - Harith was mainly concerned with consolidating Muslim authority in Albania , campaigning along the Cyrus against the regions of al - Lakz and Khasmadan . He was probably also preoccupied with supervising that year ' s census . In the next year , however , Barjik , one of the Khazar " khagan " s sons , launched a major invasion of Albania and Azerbaijan . The Khazars even laid siege to Warthan , during which they employed mangonels , a fact which , according to K . Y . Blankinship , shows that the Khazars were " a militarily sophisticated nation , not a mere disorganized pack of barbarians " . Al - Harith was able to defeat them on the banks of the Araxes and drive them back north of the river , but the Arabs ' position was clearly precarious . This prompted Maslama to take over personally the direction of the Khazar front in 727 , where now he was faced , for the first time , by the " khagan " himself , as both sides escalated the conflict . Maslama , probably reinforced with more Syrian and Jaziran troops , took the offensive . He recovered the Darial Pass , lost in the meantime , and pushed on into Khazar territory , campaigning there until the onset of winter forced him to return to Azerbaijan . What he achieved in this expedition is unclear , but in the next year , when he repeated his invasion , it ended in what K . Y . Blankinship calls a " near disaster " . Arab sources report that the Arab troops fought for 30 or even 40 days in the mud , under continuous rainfall , before scoring a victory against the " khagan " on 17 September 728 . How great that victory was , however , is open to question , because on his return Maslama was ambushed by the Khazars , whereupon the Arabs simply abandoned their baggage train and fled headlong through the Darial Pass to safety . In the aftermath of this campaign , Maslama was replaced yet again by al - Jarrah al - Hakami . For all his energy , Maslama ' s campaigning failed to produce the desired results : by 729 , the Arabs had lost control of northeastern Transcaucasia and been thrust again into the defensive , with al - Jarrah again having to defend Azerbaijan against a Khazar invasion . Ardabil and the Arab reaction . In 730 , al - Jarrah went to the offensive through Tiflis and the Darial Pass . Arab sources report that he reached as far as the Khazar capital , al - Bayda , on the Volga , but modern historians such as Blankinship consider this improbable . The Khazars launched a counterstroke under a certain Tharmach , which forced al - Jarrah to retreat south of the Caucasus once again to defend Albania . It is unclear whether the Khazars came through the Darial Pass or the Caspian Gates , but they managed to move around al - Jarrah ' s army at Bardha ' a and lay siege to Ardabil . The city was the capital of Azerbaijan , and the mass of the Muslim settlers and their families , some 30 , 000 in total , lived within its walls . When al - Jarrah learned of this , he led his army in a rapid march south and engaged the Khazars outside the city walls . There , after a three - day battle on 7 – 9 December 730 , al - Jarrah ' s army of 25 , 000 was all but annihilated by the Khazars under Barjik . Al - Jarrah also fell and command passed to his brother al - Hajjaj , who was unable to prevent the sacking of Ardabil . The 10th - century historian Agapius of Hierapolis reports that the Khazars took as many as 40 , 000 prisoners from the city , al - Jarrah ' s army , and the surrounding countryside . The Khazars raided the province at will , sacking Ganza and attacking other settlements , with some detachments reaching as far as Mosul in the northern Jazira , adjacent to the Umayyad metropolitan province of Syria . The defeat at Ardabil was a major shock to the Muslims , who for the first time faced an enemy so deep within the heartland of the Caliphate . 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 dinar s 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 Bajarwan 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 the result of the jealousy of Maslama , whom Hisham re - appointed as governor of Armenia and Azerbaijan . 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 may be confused with that of 728 , it appears that he took Khamzin , 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 Qinnasrini 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 . In summer 732 , Marwan led 40 , 000 men north into Khazar lands . The accounts of this campaign are confused : Ibn A ' tham records that he reached Balanjar and returned to Derbent with much captured livestock , but the campaign is described in terms strongly reminiscent of Maslama ' s expeditions in 728 and 731 , and hence are open to doubt . Ibn Khayyat on the other hand reports that Marwan led a far more limited campaign on the country immediately to the north of Derbent and then retired there to spend the winter . Marwan was more active in the south , where he raised Ashot III Bagratuni to the position of presiding prince of Armenia , effectively granting the country large - scale autonomy in exchange for the service of its soldiers alongside the Caliphate ' s armies . This unique concession points , according to Blankinship , to the worsening manpower crisis faced by the Caliphate . At about the same time , the Khazars and Byzantines strengthened their ties and formalized their alliance against their common enemy with the marriage of Constantine , the son and heir of emperor Leo III the Isaurian ( r . 717 – 741 ) , to the Khazar princess Tzitzak . Final phase of the war . After Marwan ' s 732 expedition , a period of quiet set in . Marwan was replaced as governor of Armenia and Azerbaijan in spring 733 by Sa ' id al - Harashi , but he undertook no campaigns at all until 735 , when he lost his sight and resigned . Marwan was then re - appointed to the post , but he too was unable to launch anything but local expeditions until 737 : three fortresses near the Darial Pass and the ruler of a North Caucasian principality , Tuman Shah , were captured in 735 , while another local prince , Wartanis , was defeated and killed in 736 . Blankinship attributes this inactivity to the exhaustion of the Arab armies and draws a parallel with the contemporaneous quiet phase in Transoxiana in 732 – 734 , where the Arabs had also suffered a series of costly defeats at the hands of Turkic nomads . In addition , Agapius and Michael the Syrian record that the Arabs and the Khazars concluded peace , information which Muslim sources ignore or downplay to a tactical ruse by Marwan designed to gain time for his preparations . The Arabs prepared a massive strike for 737 , however , intended to end the war for good . Marwan apparently went to Damascus in person to persuade Hisham to back this project and was successful : an army 120 , 000 strong was assembled , comprising regular forces of Syria and the Jazira , as well as volunteers for the " jihad " , Armenian troops under Ashot Bagratuni , and even armed camp followers and servants . The number is clearly an exaggeration , but whatever the real size of Marwan ' s army , it was a huge force and certainly the largest ever sent against the Khazars . Marwan first secured his rear by subduing the Armenian factions who were hostile to the Arabs and their client Ashot . He then pushed into Iberia , driving its Chosroid ruler to seek refuge in the fortress of Anakopia on the Black Sea coast , in the Byzantine protectorate of Abkhazia . Marwan laid siege to Anakopia itself , but he was forced to retire due to the outbreak of dysentery among his troops . With Transcaucasia subdued , Marwan now launched a two - pronged offensive against the Khazars : 30 , 000 men under the governor of Derbent , Asid ibn Zafir al - Sulami , advanced north along the coast of the Caspian Sea , while Marwan himself with the bulk of his forces crossed the Darial Pass . The two armies met at Samandar , and from there Marwan pushed on , reaching , according to some Arab sources , the Khazar capital of Atil ( al - Bayda ' ) on the Volga . Most Arab sources contain few details on the campaign , but Ibn A ' tham reports that Marwan attacked the Slavs and took 40 , 000 captives . As the Khazars avoided battle , he then sent a detachment of 40 , 000 troops across the Volga under al - Kawthar ibn al - Aswad al - ' Anbari , which surprised the Khazars in a swamp . In the ensuing battle , the Arabs killed 10 , 000 Khazars , including the " tarkhan " , and took 7 , 000 captive . Thereupon the Khazar " khagan " himself is said to have requested peace and to have converted to Islam and recognized the Caliph ' s authority . Marwan also took with him large numbers of Slav and Khazar captives , whom he resettled in the eastern Caucasus : some 20 , 000 Slavs were settled at Kakheti , according to al - Baladhuri , while the Khazars were resettled at al - Lakz . The Slavs , however , killed their Arab governor and fled north , but Marwan rode after them and killed them . Marwan ' s 737 expedition was the climax of the Arab – Khazar wars , but its actual results were meagre . Although the Arab campaigns after Ardabil may indeed have discouraged the Khazars from further warfare , any recognition of Islam or of Arab supremacy by the " khagan " was evidently conditional upon the presence of Arab troops deep in Khazar territory , and such presence could not be sustained for long . Furthermore , the credibility of the conversion of the " khagan " to Islam is disputed : al - Baladhuri ' s account , which probably reflects closer the original sources , suggests that it was not the " khagan " but a minor lord who converted to Islam and was placed in charge of the Khazars at al - Lakz . The conversion of the " khagan " is also apparently contradicted by the fact that c . 740 the Khazar court embraced Judaism as its official faith , a decision which clearly owed a great deal to the determination of the Khazars to avoid assimilation by and emphasize their independence from the Christian Byzantine and the Muslim Arab empires . Whatever the true impact of Marwan ' s campaigns , warfare between the Khazars and the Arabs ceased for more than two decades after 737 . Arab military activity in the Caucasus continued until 741 , with Marwan launching repeated expeditions against the various princes of the northern Caucasus , most notably Tuman Shah . Nevertheless , these campaigns , according to Blankinship , seem to have been closer to raids , designed to seize plunder and extract tribute to pay for the upkeep of the Arab army , rather than attempts at permanent conquest . Despite the Umayyad success at establishing a more or less stable frontier anchored at Derbent , Blankinship is also critical of the long - term results of the Second Arab – Khazar War : Arab control was in reality limited to the lowlands and coast , and the land itself was too poor to recompense the expenses sustained during the wars . Furthermore , the need to maintain the large garrison at Derbent further depleted the already overstretched Syro - Jaziran army , the main pillar of the Umayyad regime . Eventually , this weakening of the Syrian army would be the major factor in the fall of the Umayyad dynasty during the civil wars of the 740s and the Abbasid Revolution that followed them . Later conflicts . The Khazars resumed their raids on Muslim territory after the Abbasid succession , reaching deep into Transcaucasia . Although by the 9th century the Khazars had re - consolidated their control over Dagestan almost to the gates of Derbent itself , they never seriously attempted to challenge Muslim control of the southern Caucasus . The first conflict between the Khazars and the Abbasids resulted from a diplomatic manoeuvre by the Caliph al - Mansur ( r . 754 – 775 ) . Attempting to strengthen the Caliphate ' s ties with the Khazars , in c . 760 , he ordered his governor of Armenia , Yazid ibn Asid ibn Zafir al - Sulami , to marry a daughter of the " khagan " Baghatur . The marriage indeed took place amidst much celebration , but she died in childbirth two years later , along with her infant child . The " khagan " suspected the Muslims of poisoning his daughter , however , and he launched devastating raids south of the Caucasus in 762 – 764 : under the leadership of a Khwarezm ian " tarkhan " named Ras , the Khazars devastated Albania , Armenia , and Iberia , where they captured Tiflis . Yazid himself managed to escape capture , but the Khazars returned north with thousands of captives and much booty . A few years later , however , in 780 , when the deposed Iberian ruler Nerse tried to induce the Khazars to campaign against the Abbasids and restore him to his throne , the " khagan " refused . This was probably the result of a brief period of anti - Byzantine orientation in Khazar foreign policy , resulting from disputes between the two powers in the Crimea . During the same period , the Khazars helped Leon II of Abkhazia throw off Byzantine overlordship . Peace reigned in the Caucasus between Arabs and Khazars until 799 , when the last major Khazar attack into Transcaucasia took place . Chroniclers again attribute this attack to a failed marriage alliance . According to Georgian sources , the " khagan " desired to marry the beautiful Shushan , daughter of Prince Archil of Kakheti ( r . 736 – 786 ) , and he sent his general Buljan to invade Iberia . Most of the central region of K ' art ' li was occupied , and Prince Juansher ( r . 786 – 807 ) was taken off into captivity for a few years , but Shushan committed suicide and the furious " khagan " had Buljan executed . Arab chroniclers , on the other hand , attribute this to the plans of the Abbasid governor al - Fadl ibn Yahya ( one of the famous Barmakids ) to marry one of the " khagan " s daughters , who died on her journey south , while a different story is reported by al - Tabari , whereby the Khazars were invited to attack by a local Arab magnate in retaliation against the execution of his father , the governor of Derbent , by the Arab general Sa ' id ibn Salm . According to the Arab sources , the Khazars then raided as far as the Araxes , necessitating the dispatch of troops under Yazid ibn Mazyad as the new governor of Transcaucasia , with more forces under Khazim ibn Khuzayma in reserve . Arabs and Khazars continued to clash sporadically in the North Caucasus in the 9th and 10th centuries , but warfare was localized and of far lower intensity than the great wars of the 8th century . Thus the Ottoman historian Münejjim bashi records a period of warfare lasting from ca . 901 until 912 , perhaps linked to the Caspian raids of the Rus ' at about the same time , to whom the Khazars allowed passage . With the progressive collapse of Khazar power in the 10th century and defeats at the hands of the Rus ' and other Turkic nomads like the Oghuz Turks , the Khazar realm contracted to its core around the lower Volga , and became removed from reach of the Arab Muslim principalities of the Caucasus , putting an end to their conflicts . Thus Ibn al - Athir ' s reports of a war between the Shaddadids of Ganja with the Khazars in 1030 is probably an erroneous reference to the Georgians . Finally , Münejjim bashi records that in 1064 , " the remnants of the Khazars , consisting of three thousand households , arrived in Qahtan [ somewhere in Dagestan ] from the Khazar territory . They rebuilt it and settled in it .