The Mongol invasion of Ossetia, then known as Alania, began in 1221 and culminated with the Mongol victory at the Siege of Maghas in 1240. In the winter of 1238, The Mongol army, which had been stationed in Circassia, invaded western Alania, today's Karachay-Cherkessia. In November 1239, the Mongols besieged Maghas, the capital city of Alania.
First invasion
The Mongol troops turned northeast from Circassia to reach Derbent through Shirvan. Their further movement is described in detail by the Arab historian Ibn Al-Athir (1166–1238) and the Persian historian Rashid al-Din Hamadani (1247–1318). Rashid al-Din Hamadani reports that "since it was impossible to pass through Derbent" the Mongols decided to feint. they turned to the Shirvanshah with a proposal to make peace and requested ten representatives of the local nobility be sent to the Mongolian camp. However, "(one) of them (the Mongols) was killed, and the others were told: 'If you show us the way through Derbent, we will spare you, otherwise we will kill you too.' Alans were out of fear for their life and showed the way, and they passed."
The text of Rashid Ad-Din does not directly indicate that the inhabitants of Derbent resisted the Mongol troops, saying only that "it was impossible to pass through Derbent". Comparison with the data of other authors suggests that the residents of Derbent did not allow the conquering troops into the city. Kirakos Gandzakti writes that "The Muslim army that was there did not let them through." In the Chronicle of Sebastatsi Murad this idea is clearly expressed: "And the Turkish troops that were in Derbent did not let them through". Thus the Mongol troops chose a path around Derbent.
The Mongol troops crossed through "impregnable places, filling up the gaps with trees and stones, their property, horses and military equipment". The only road the Mongols could use to reach the Northern Caucasus, ran through inland Dagestan along impassable mountains. Having bypassed Derbent, they likely could have reached the coastal part of Dagestan, but sources give reason to believe that the Tatar-Mongols passed through inland Dagestan:
"Having passed Derbent and Shirvan, the Tatars entered the regions in which there are many nationalities: Alans, Lezgs and several Turkic tribes (Taifa), robbed and killed many Lakzee Muslims and non-believers and carried out massacres among the inhabitants of those countries who met them with hostility and reached the Alans, consisting of many nationalities". There the Tatar-Mongols met stubborn resistance from the residents of the North Caucasus mountains.
Following further north, the Tatar-Mongols "arrived to the Alans, the people numerous, to whom news of them has already reached." As a form of alliance with the Kipchaks (Polovtsy in Russian chronicles) also became Alans. The leaders of the Mongol troops, Jebe and Subedei, decided to split the alliance of Alans and Kipchaks by bribing the latter. For this purpose, the Tatar-Mongols turned to the Kipchaks: "We and you are one people and from the same tribe, The Alans are strangers to us, we make an agreement with you that we will not attack each other and will give you as much gold and clothes as our soul your wish, (just) present them (the Alans) to us". The plot was successful.