After his father Tekish died, Muhammad succeeded him. Right after his accession, however, his domains were invaded by the two Ghurid brothers Ghiyas ad-Din Ghori and Mu'izz al-Din. Within weeks, the two brothers had moved their armies westwards into Khorasan. Once they had captured Nishapur, Mu'izz al-Din was sent on an expedition towards Ray, but he let his troops get out of control and got little further than Gurgan, earning criticism from Ghiyas which led to the only reported quarrel between the brothers. Ghiyas died at Herat in 1202 after months of illness. Muhammad II used this opportunity to invade the domains of the Ghurid Empire, and besieged Herat. Mu'izz, however, managed to repel him from Herat and then pursued him to Khwarezm, besieging Gurganj, his capital. Muhammad desperately requested aid from the Kara-Khitan Khanate, who sent an army to aid Muhammad. Mu'izz, because of the pressure from the Kara-Khitans, was forced to relieve the siege and retreat. However, on his way to his domains in Ghur, he was defeated at Andkhud in 1204. Mu'izz al-Din was later assassinated in 1206, throwing the Ghurid Empire into a civil war. During the civil war, Ghiyath al-Din Mahmud managed to emerge victorious. However, Ghiyath's Turkic general Tajuddin Yildoz seized Ghazni from the Ghurid rulers of Bamiyan, but shortly recognized the authority of Ghiyath. Ghiyath, not glad about Tajuddin controlling Ghazni, and not daring to leave Ghur unprotected, requested help from the Muhammad II. Muhammad, however, instead invaded the domains of Ghiyath, capturing Balkh and Tirmidh. However, during his invasion he was captured by the Kara-Khitan Khanate. Thirteen months later, Muhammad was freed from captivity, and once again invaded the domains of Ghiyath, and captured Herat. Muhammad then invaded the Ghurid heartland of Ghur, and captured Ghiyath. Ghiyath then agreed to recognize Muhammad's authority. Muhammad II then captured Samarkand in 1207 from the Kara Khitay, Tabaristan in 1210 from Bavandids and Transoxiana from Western Karakhanids. He pursued expansionist policy and conquered Tashkent and Fergana from Western Karakhanids and regions of Makran and Balochistan from Ghurids and Atabegs of Azerbaijan become his vassals in 1211. He finally destroyed Western Karakhanids in 1212 and Ghurids in 1215 annexing with their remainder territories. During 1212 the city of Samarkand revolted killing 8,000–10,000 Khwarezmians living there. Muhammad, in retaliation, sacked the city and executed 10,000 citizens of Samarkand. By 1217, he had conquered all the lands from the river Jaxartes to the Persian Gulf. He declared himself shah and demanded formal recognition from the caliph in Baghdad. When the caliph an-Nasir rejected his claim, Ala ad-Din Muhammad gathered an army and marched towards Baghdad to depose an-Nasir. However, when crossing the Zagros Mountains, the shah's army was caught in a blizzard. Thousands of warriors died. With the army decimated, the generals had no choice but to return home.
Fall
In 1218, a small contingent of Mongols crossed borders in pursuit of an escaped enemy general. Upon successfully retrieving him, Genghis Khan made contact with the Shah. Having only recently conquered two-thirds of what would one day be China, Genghis was looking to open trade relations, but having heard exaggerated reports of the Mongols, the Shah believed this gesture was only a ploy to invade his land. Genghis sent emissaries to Khwarezm to emphasize his hope for a trade road. The Shah, in turn, had one of his governors openly accuse the party of spying, their rich goods were seized and the party was arrested. '' by Rashid-al-Din Hamadani Trying to maintain diplomacy, Genghis sent an envoy of three men to the Shah, to give him a chance to disclaim all knowledge of the governor's actions and hand him over to the Mongols for punishment. The shah executed the envoy, and then immediately had the Mongol merchant party put to death. These events led Genghis to retaliate with a force of 100,000 to 150,000 men that crossed the Jaxartes in 1219 and sacked the cities of Samarkand, Bukhara, Otrar and others. Muhammad's capital city, Urgench, followed soon after. Genghis Khan's revenge was considered brutal, even by Mongol standards. His campaign resulted in the complete annihilation of Khwarezm cities, destruction of countless historical artifacts and records, and arguably the bloodiest massacre the world saw until the 20th century.
Death
Ala ad-Din Muhammad fled and sought refuge throughout Khorasan, and later died of pleurisyon an island in the Caspian Sea near the port of Abaskun some weeks later.