[3]: 12 Of these two major vassals, the Qarakhanids were by far the more prestigious; they had ruled in the area for two centuries, and controlled many of the richest cities in the region, such as Bukhara, Samarkand, Tashkent and Fergana.
[3]: 13–14 However, as the Seljuk Empire slowly fractured after the death of Ahmad Sanjar in 1154, the Khwarazmids were able to take advantage of the chaos due to their geographical proximity; Il-Arslan's son Tekish captured large cities such as Nishapur and Merv in the nearby region of Khorasan, gaining enough power to declare himself a fully-fledged sovereign in 1189.
[5] Tekish now ruled a great swathe of territory stretching from Hamadan in the west to Nishapur in the east; drawing on his newfound strength, he threatened war with the caliph, who reluctantly accepted him as Sultan of Iran and Khorasan in 1198.
In the early thirteenth century, the khanate would be destabilized further by refugees fleeing the conquests of Genghis Khan, who had begun to establish hegemony over the Mongol tribes.
Despite a troubled early start to his reign, which saw conflict with the Ghurids of Afghanistan, he followed his predecessor's expansionist policies by subjugating the Qarakhanids and taking their cities, including Bukhara.
[7] In 1211, Kuchlug, a prince of the Naimans, managed to usurp the Qara-Khitai Empire from his father-in-law Yelü Zhilugu with Muhammad's help, but alienated both his subjects and the Khwarazmshah with anti-Muslim measures.
The chronicler Al-Nasawi attributes this change in attitude to the memory of an unintended earlier encounter with Mongol troops, whose speed and mobility frightened the Shah.
[9] It is also likely that the Shah had grown in pride — like his father, he was now embroiled in a dispute with the Abbasid caliph Al-Nasir, and even went so far as to march on Baghdad with an army, but was repulsed by a blizzard in the Zagros Mountains.
[12] The validity of the accusations has been debated, as has the Shah's involvement; it is certain, though, that he rejected the Khan's subsequent demands that Inalchuq be punished, going so far as to kill one Mongol envoy and humiliate the other two.
[14]: 113 The medieval chronicler Rashid al-Din Hamadani attested that the Mongol army numbered over 600,000 strong, and that they were opposed by 400,000 total Khwarazmians;[15] his contemporary Juzjani gives an even greater estimate of 800,000 for the Khan.
[21] As for the Khwarazmians, there is no similarly reliable contemporary source; Sverdrup, taking the proportional exaggeration of the Muslim forces as equal to that of the Mongols, has estimated a total of around 40,000 soldiers, excluding certain town militias.
[24] The Shah also distrusted most of his commanders, with the only exception being his eldest son and heir Jalal al-Din, whose military acumen had been critical on the Irghiz River the previous year.
Rashid Al-Din stated that Otrar had a garrison of 20,000 while Juvayni claimed 60,000 (horsemen and militia), though like the army figures given in most medieval chronicles, these numbers should be treated with caution and are probably exaggerated by an order of magnitude considering the size of the city.
Inalchuq held out until the end, even climbing to the top of the citadel in the last moments of the siege to throw down tiles at the oncoming Mongols and slay many of them in close quarters combat.
Genghis then compounded the damage by repeatedly issuing bogus decrees in the name of either Terken Khatun or Shah Muhammad, further tangling up the already divided Khwarazmian command structure.
[36] As a result of the Mongol strategic initiative, speedy manoeuvres, and psychological strategies, all the Khwarazmian generals, including the Queen Mother, kept their forces as a garrison and were defeated in turn.
[38][39] As Genghis began his siege, his sons Chaghatai and Ögedei joined him after finishing the reduction of Otrar, and the joint Mongol forces launched an assault on the city.
The Persian scholar Juvayni states that 50,000 Mongol soldiers were given the task of executing twenty-four Gurganj citizens each, which would mean that 1.2 million people were killed.
[citation needed] After capturing Balkh in early 1221 and while continuing to besiege Taliqan, Genghis dispatched his youngest son Tolui to Khorasan to make sure that no opposition remained in the extensive and wealthy region.
[41] Tolui's army was composed of a tenth of the Mongol invasion force augmented by Khwarazmian conscripts; the historian Carl Sverdrup estimates its size at around 7,000 men.
[43] He marched westwards from Balkh to Murichaq, on the present-day Afghanistan–Turkmenistan border, and then crossed the Marghab river and its tributary the Kushk to approach the city of Merv from the south.
Having been subjected to a general assault on the seventh day, the townspeople, who twice attempted a sortie to no effect, lost the will to resist and surrendered to the Mongols, who promised to treat them fairly.
[45] Tolui, however, reneged on this guarantee, and ordered that the entire population be driven out on the plain and put to the sword, excluding a small number of artisans and children.
The early 20th-century historian Vasily Bartold, citing a local history from the 1400s, stated that none of the inhabitants were killed with the exception of the garrison; meanwhile, the chronicler Minhaj-i Siraj Juzjani, who fought the Mongols nearby, recorded that after an eight-month siege, the city was taken and its population slaughtered.
[55] The population subsequently rebelled and were besieged for months by the Mongol general Eljigidei, who was said to have killed between 1,600,000 and 2,400,000 people during his sack of the town, in a massacre lasting seven days in June 1222.
[59] The historian Michal Biran has suggested that the speed with which the Mongols brought the pragmatically brutal warfare of East Asia into the less ruthless Muslim world was a factor in this cultural shock.
Genghis Khan led the main army on a raid through Afghanistan and northern India towards Mongolia, while another 20,000 (two tumen) contingent marched through the Caucasus and into Rus', Armenia and Azerbaijan under generals Jebe and Subutai.
He retook control of areas of western Iran, in Kerman, Tabriz, Isfahan and Fars, but was eventually defeated by the Rum Seljuk Sultan Kayqubad I at the Battle of Yassıçemen in 1230.
[66] The Mongols came back to conquer the western areas of the former Khwarazmian Empire in 1230–1231, at the time of Genghis Khan's successor Ögedei, who sent an expedition of three tumens led by general Chormaghun.
[67] The Mongols under Chormaghun established themselves in northwestern Iran, from where they were able to raid the neighbouring territories of Armenia, Azerbaijan and Mosul during the next ten years, culminating with the invasion of Georgia in 1236.