Khwarazmshah was an ancient title used regularly by the rulers of the Central Asian region of Khwarazm starting from the Late Antiquity until the advent of the Mongols in the early 13th-century, after which it was used infrequently.
The city had risen to rival the Afrighid capital of Kath, most likely due to its commercial success as a trading post between the steppe and the Kievan Rus'.
Abu'l-Harith Muhammad was deposed and imprisoned, while Khwarazm was incorporated into the Ghaznavid realm, thus marking the end of the Ma'munid dynasty, the last ethnically Iranian line of Khwarazmshahs.
[7][6] A loyal servant of the Ghaznavids, Altuntash protected the borders of Khwarazm by enlisting additional soldiers from the Turkic groups of Qipchaq, Kujet and Chaghrat.
From henceforth Khwarazm was a Seljuk province, although the title of Khwarazmshah was unused until c. 1077, when the Turkic ghulam Anushtegin Gharchai was made its governor by Sultan Malik-Shah I (r. 1072–1092).
It was his son and successor Atsiz (r. 1127/8–1156) who established the Khwarazmshahs' grandeur, being determined in his pursuit of autonomy and expansion of his realm, conquering the Turkmens of the eastern Caspian shores and the Manghislak peninsula.
As long as he paid tribute to the Qara Khitai, they had little interest in meddling in his affairs, and thus he was free to focus on expanding his rule into the Qarakhanid domains.
[8] The power of the Khwarazmshahs even further increased under Il-Arslan's son and successor Ala al-Din Tekish (r. 1172–1200) was able to slow down the Ghurid expansion into Khurasan and destroy the Seljuk Empire.
His son and successor Muhammad II (r. 1200–1220) was occupied with his rivals in the east (Ghurids, Qara Khitai, the Qipchaq of the northern steppes, and the Qarakhanids) for much of his reign.
He initially maintained cordial relations with the Qara Khitai, who helped him fend off the 1204 invasion of Khurasan by the Ghurid ruler Mu'izz al-Din Muhammad Ghuri (r. 1173–1206), who later died in 1206.
[11] Muhammad II was now a towering figure in the eastern Islamic world, but like his father, was content with the limited titles of Khwarazmshah and Sultan.
He now sought to the deal with the Abbasid Caliphate, who had in the past supported the Ghurids against him; he marched towards Baghdad, but the extreme weather conditions during the winter and unrest amongst the Qipchaq forced him to return to Khwarazm.