Read the story
The khan had just lost a battle. So he offered peace, and one sensible-sounding favor: split your army into five groups, because Khiva cannot feed you all in one place.
It was 1717. The Russian commander was Prince Alexander Bekovich-Cherkassky, the son of a ruler of Kabarda, a Muslim-born convert to Christianity in Russian service. Peter the Great had sent him to build forts, open a trade road toward India, and bring the khan of Khiva to heel.
Shir Gazi Khan's army attacked, and the Russians drove it off. Then came the offer. Bekovich accepted, and once his men were scattered, they were killed or enslaved; only a few escaped. Bekovich himself was executed, by one account beheaded in front of the khan. Even that is disputed, because the story comes from those few survivors.
In 1873, Russia came back. General Konstantin von Kaufmann, Governor-General of Turkestan, sent some 13,000 troops into the desert in four columns. One, out of Krasnovodsk, ran out of water and turned back. Kaufmann's own column ran dry too, camels dying, supplies abandoned in the sand.
On June 9th, an advance party reached Khiva's North Gate under heavy fire. The next day, artillery smashed that gate, and Skobelev charged through with a thousand men, then pulled back. Kaufmann was entering the city peacefully, by one account through this West Gate.
The khan, Muhammad Rahim Khan the Second, a poet who wrote as Feruz, had fled to hide among the Yomut Turkmen. Kaufmann called him back and reinstated him. That August, the khan signed himself a vassal of the Russian emperor, gave up land across the Amu Darya, agreed to pay 2.2 million rubles, and abolished slavery.
Shir Gazi Khan had beaten Russia by persuading it to break itself apart. Kaufmann kept the khan whole and took away everything the throne had meant. Khans would rule behind these walls until 1920, but only with Russia's permission.