Khorezm: The Civilisation Before the Khanate
Khorezm before Khiva: the Afrighids, the Khwarazmshahs, al-Biruni and al-Khwarizmi, the Mongol catastrophe of 1221, and the desert forts you can still visit.

Every time you use the word algorithm you are saying a place name. It comes, through Latin, from al-Khwarizmi — “the man from Khwarazm” — the ninth-century mathematician whose book on calculation gave Europe both that word and, from its title, algebra. Khwarazm, Khorezm, Khorazm: the same region, spelled a dozen ways, and today a province of northwestern Uzbekistan that most travellers pass through in an afternoon on their way to Khiva.
Khiva is not the story. Khiva is what was left. The civilisation that produced the name in your maths textbook was already ancient when the Khivan khanate was founded in the sixteenth century, and its capital was seventy miles away in what is now Turkmenistan.
A delta, not a country
Start with the geography, because everything else follows from it.
The Amu Darya — the Oxus of classical writers — runs out of the Pamirs and, before the twentieth century, emptied into the Aral Sea through a shifting delta. Around that delta, surrounded on all sides by the Kyzylkum and Karakum deserts, irrigation could support a dense agricultural population. Nowhere else within several hundred kilometres could. Khorezm was an island of farmland in sand, and that isolation shaped it: a distinct language, a distinct calendar, a distinct Zoroastrian-influenced religious culture, and a political history that ran separately from Samarkand and Bukhara for most of two thousand years.
It also made the place fragile in a specific way. When a river changes course, or a canal system is destroyed, the farmland does not recover on its own. That is the thread running through everything below, including the modern Aral catastrophe.
The Afrighids, and the forts in the desert
The dynasty usually called the Afrighids is traditionally dated from 305 CE, a figure that comes to us from al-Biruni, who counted twenty-two rulers spanning some 690 years. Treat that as a scholarly tradition recorded three centuries after the fact rather than a documented king list.
They ruled from Kath, on the right bank of the Amu Darya, where Afrig is said to have built a fortress called Fil. The Arab conquest under Qutayba ibn Muslim reached Khorezm in 712 and the Afrighids survived it as vassals, which is unusual — most Central Asian dynasties did not. They lasted until 995, when they were displaced by the Ma’munids of Gurganj on the opposite bank.
What you can actually see from this period, and earlier, are the desert fortresses. Fifty-odd mudbrick citadels, some of them pre-Islamic and dating back two thousand years, stand in the desert north and east of the delta in what is now Karakalpakstan. They were excavated seriously only from the 1930s. They are the single most impressive surviving thing from ancient Khorezm, and they are visitable — our guide to the Elliq Qala fortresses covers which ones are worth the drive.
Two scholars
Khorezm’s intellectual reputation rests on two men, and it is worth being precise about both.
Muhammad ibn Musa al-Khwarizmi, roughly 780–850, worked at the House of Wisdom in Baghdad under the Abbasid caliph al-Ma’mun. His treatise on completion and balancing gave us algebra; the Latin transliteration of his name gave us algorithm; and his work on Hindu-Arabic numerals is why you are not reading this in Roman numerals. His connection to Khorezm is the usual reading of his name, though at least one early Arabic source places his family elsewhere, and historians have argued about it for a century. The region claims him, and the claim is more likely right than wrong.
Abu Rayhan al-Biruni is the firmer case. Born in Kath on 4 September 973, he left after the Afrighid collapse in 995 and moved between the courts of Gurganj, Tabaristan and eventually Ghazna. He measured the Earth’s radius with a method involving a mountain and a horizon, wrote the most serious study of India produced by any medieval outsider, catalogued Khorezm’s own pre-Islamic calendar before it vanished, and did it all in a career spent largely as a court dependent of rulers he did not choose.
Both of them are on the currency and on statues in Urgench and Khiva. Neither of them worked in the buildings you will be photographing.
One more thing al-Biruni preserved, almost by accident. Pre-Islamic Khorezm ran its own solar calendar with twelve thirty-day months and five extra days, and its own festival cycle, distinct from both the Persian and the Sogdian systems. He recorded the month names and the feast days in a book written in Arabic in the 1000s, roughly three centuries after the culture that used them had begun to disappear. Nearly everything we know about Khorezmian religious practice before Islam comes from that one act of note-taking by a man who had already left.
The Khwarazmshahs, and the empire nobody remembers
Khwarazmshah was a title, not a dynasty, and four separate families held it: the Afrighids to 995, the Ma’munids to 1017, the line of Altuntash to 1041, and finally the Anushteginids from 1097.
That last family is the one that matters. They began as Seljuk appointees — the founder was a royal cup-bearer — and over a century they turned a provincial governorship into the largest empire in the Islamic east. At its height under Ala ad-Din Muhammad II, the Khwarazmian state ran from the edge of Anatolia to the Hindu Kush and included Samarkand, Bukhara, Herat and much of Iran. Gurganj, the capital, was one of the great cities of the world.
It lasted about twenty years at that size.
1219–1221
The standard account is that the governor of Otrar, a Khwarazmian frontier town, seized a Mongol trade caravan in 1218 and executed the merchants as spies. Muhammad II then had one of Genghis Khan’s envoys killed. Whether Genghis needed the pretext or simply used it is one of the genuinely open questions in the period, and historians differ.
What followed was not a war so much as a demolition. Mongol armies crossed the Syr Darya in 1219, took Otrar, Bukhara and Samarkand in succession, and reached Gurganj in 1221. The city held out for months. When it fell, the Mongols are said to have broken the dams on the Amu Darya and flooded the ruins — a detail repeated in the medieval sources and impossible to verify, but consistent with the fact that the site was never rebuilt on the same spot.
Muhammad II died on an island in the Caspian, hunted. His son Jalal al-Din Mangburni fought a long retreat through Afghanistan and Iran from December 1220 until his death on 15 August 1231, and is a national hero in modern Uzbekistan — the high-speed train to Khiva carries his name.
The irrigation system took centuries to recover. Some of it never did. If you want the wider frame for what the Mongol century did to the region’s cities, our Silk Road history sets it out, and Timur’s rise a century and a half later is the sequel.
Where the capital actually was
This trips people up constantly, so plainly: old Gurganj, the Khwarazmshah capital, is Konye-Urgench, and it is in Turkmenistan, about 150 km northwest of Khiva across a border that is not casually crossed. It is a UNESCO World Heritage Site in its own right.
Modern Urgench, in Uzbekistan, is a different place founded much later — the city you fly into for Khiva, and a Soviet-planned grid with almost nothing medieval left standing. Kath, the Afrighid capital, has largely been eaten by the river; its approximate successor is the town of Beruniy in Karakalpakstan.
Which leaves a slightly awkward fact for the traveller. The most important city in Khorezmian history is not in Uzbekistan, and the most famous one, Khiva, was a secondary town until the seventeenth century, when the Amu Darya shifted away from Gurganj’s successor at Urgench and the khans moved their seat. Khiva is a capital of convenience that got lucky with preservation. That’s covered in our history of the khanate.
What survives, and where
Inside Uzbekistan, the pre-Khivan layer is thin on the ground but not absent.
- The desert fortresses of Elliq Qala, north and east of Urgench, the oldest and most atmospheric survivals.
- Mizdakhan, near Nukus, a necropolis with continuous burial over roughly two thousand years and a ruined fortress alongside — see our write-up.
- Hazarasp, one of the three great Khorezmian cities named in the Islamic sources, still a town with a ruined citadel 40 km east of Khiva.
- The Savitsky Museum in Nukus, whose archaeology collection holds material from the fortress excavations alongside its better-known avant-garde paintings.
And the language. Khorezmian, an Eastern Iranian language al-Biruni wrote about and partly recorded, died out around the thirteenth or fourteenth century, displaced by Turkic. The Karakalpaks and Uzbeks who live in the delta now speak Turkic languages. Nothing in Khorezm today is linguistically continuous with the civilisation that named the algorithm. That is an unusual kind of loss, and it is the kind of thing worth sitting with for a few minutes on the road in from the airport, when the window is showing you nothing but cotton fields and canals.
If you are going to give this history one day rather than one afternoon, spend it in Karakalpakstan rather than in Khiva. The forts and Mizdakhan tell you far more about what Khorezm actually was than the walled city does, and on most days almost nobody else goes.
Sources: Britannica on Khwarezm for the dynastic sequence; UNESCO on Kunya-Urgench for the fate of the Khwarazmshah capital. Dates before the Islamic period rest on al-Biruni’s own account and are traditional rather than documented.
Featured image: Betta27 (Public domain) via Wikimedia Commons.