The Afrighids (Khwarazmian: ʾfryḡ) were a native Khwarezmian Iranian dynasty who ruled over the ancient kingdom of Khwarazm. Over time, they were under the suzerainty of the Sasanian Empire, the Hephthalite Empire, the Göktürk Khaganate, the Umayyad Caliphate, Abbasid Caliphate and the Samanid Empire.
 They were ultimately deposed by a rival family, the Ma'munids of Gurganj, who became the new rulers of Khwarazm.
 Al-Biruni, the native Khwarezmian scholar, mentions twenty-two members of the Afrighid dynasty for a total span of 690 years with an average rule of 31 years for each ruler. According to him, the Afrighids ruled from 305, through the Arab conquests under Qutayba ibn Muslim in 712, and up to their overthrow in 995 by the rising rival family of Ma'munids. The main source on the Afrighids prior to Islam is also Al-Biruni. Part of the reason for the gap in information about this dynasty is mentioned by Al-Biruni.
 Al-Biruni states:
 When Qutaibah bin Moslem under the command of Al-Ḥajjāj ibn Yūsuf was sent to Khwarazmia with a military expedition and conquered it for the second time, he swiftly killed whoever wrote in the Khwarazmian native language and knew of the Khwarazmian heritage, history, and culture. He then killed all their Zoroastrian priests and burned and wasted their books, until gradually the illiterate only remained, who knew nothing of writing, and hence the region's history was mostly forgotten. It has been suggested that 'Afrigh' is the Arabicized of 'Abriz' in Persian (آبریز where water flows, a reference to the geography of Khwarazm and its abundant water). However, Dr. Parviz Azkai, in his annotations on Al-Biruni's Chronology of Ancient Nations, explains that this is a popular etymology. Azkai explains that Afrigh was originally Ap-Air-ig meaning from the Aryan descent: ap or af is the same in 'afrashtan' (Persian: افراشتن) to raise; air is the root meaning Aryan as seen in Iraj, and Eran/Iran (land of Aryan); and -ig is the suffix of relation in Iranian languages and cognate to '-ic' in English or '-ique' in French.
 Khwarazm was a well-irrigated, rich agricultural region on the lower Oxus. Bordering steppeland and desert on all sides, Khwarazm was geographically secluded from other areas of civilization, which allowed it to preserve a separate distinctive Iranian language and culture. Khwarazm was possibly the early homeland of the Iranians. In the Islamic era, the region had three main cities; Kath, Gurganj and Hazarasp.
 Most of Afrighid history is recorded by the Khwarazmian scholar al-Biruni (died 1050), whose reliability has been questioned. According to al-Biruni, the Afrighids were founded by Afrig in 305, succeeding the semi-legendary line of the Siyavushids, founded by the Iranian king Kay Khosrow. However, extensive Soviet archeological findings demonstrate that al-Biruni was in reality not well-acquainted with pre-Islamic Khwarazmian history. Coin findings show that before the advent of the Afrighids, Khwarazm was part of the Parthian Empire. The start of the Khwarazmian era seemingly took place in the early 1st-century, after they had freed themselves of Parthian rule, and established their own local dynasty of shahs. The dynastic name of "Afrighid" (Khwarazmian: ʾfryḡ) is not attested anywhere besides al-Biruni, which has led scholars to suggest that the name never existed. The Iranologist Clifford Edmund Bosworth adds that "If this [Afrig] era was actually in use, it must have been unofficial." Likewise, many of the Khwarazmshahs recorded by al-Biruni are not supported by archeological evidence; however, this may be due to scribal errors.
 The first four centuries of Afrighid rule are particularly obscure. According to al-Biruni, Afrig had a large fortress called Fil or Fir constructed on the fringe of the capital Kath, which by the time of al-Biruni was in ruins, due to the changes in the flow of the Oxus in the 10th-century. Coinage confirms the existence of the Afrighid shah Arsamuh, who lived during the time of the Islamic prophet Muhammad. Reliable information about Khwarazm first starts to appear in the early 8th-century. Khwarazm had initially been the subject of ineffective raids by the Arabs, who occasionally attacked from the neighbouring regions of Khurasan and Transoxiana. In 712, however, the Arab governor of Khurasan, Qutayba ibn Muslim, capilizated on the civil war between the shah Azkajwar II and his brother Khurrazad. Khwarazm was devastated, and Azkajwar II was killed. According to al-Biruni, the Arabs killed all Khwarazmian scholars who knew the ancient history of the country; however, according to Bosworth, this is exaggerated.
 Once the Arabs withdrew from their raid, the Shahs recovered power in Khwarezm and they continued to adhere to their ancestral faith, which according to Al-Biruni was Zoroastrianism. The local shahs continued to ally with local Iranian princes, Soghdian merchants and even Turks and Chinese in order to resist the Arabs. Khwarazm was one of the few Iranian states which survived through the early Islamic period.
 The Afrighids and the local population were most likely adherents of Zoroastrianism. The first Khwarazmshah to convert to Islam was Azkajwar-Abdallah, who ruled in the early 9th-century, perhaps coinciding with the reign of the Abbasid caliph al-Ma'mun (r. 813–833). Regardless, the Islamization of the local population was much slower. In the early 10th-century, the Khwarazmshahs were made vassals of the Samanid dynasty, a Persian family which ruled mainly in Transoxania and Khurasan. Although the Khwarazmshahs sometimes granted sanctuary to Samanid rebels, they generally ruled a peaceful domain. During the end of the Samanids, the Khwarazmshahs extended their rule as far as the northern edges of Khurasan, ruling frontier posts such as Farawa and Nasa.
 An uncertain part of Khwarazmian history is the rise of Ma'munid family, who came to rule their hometown of Gurganj, one of the three main cities of the country. The city had risen to rival Kath, most likely due to its commercial success as a trading post between the steppe and the Kievan Rus'. The Ma'munids and Afrighids eventually became rivals, with conflict soon ensuing. The Ma'munid Ma'mun I deposed and killed the Afrighid shah Abu 'Abdallah Muhammad (r. 967–995), thus marking the end of the first Khwarazmshah line of the Afrighids, and the inauguration of the second Khwarazmshah line of the Ma'munids.
 The Khwarazmian population practiced a variant of Zoroastriansm mixed with local paganism. Contrary to Iran, Zoroastrianism was not an official religion of Khwarazm, and thus did not follow strict writings. The Iran-based and Khwarazmian variants differed significantly from each other; while the remains of the deceased was buried in niches carved in rock or in arched burial chambers, while the Khwarazmians used ossuaries, which was a survival of earlier doctrines. The Khwarazmians continued to bury their dead in ossuaries until the 3rd-century, when they were replaced with stone boxes, a sign of the expanding influence of orthodox Zoroastrianism from Iran. Contrary to the orthodox Zoroastrians, the Khwarazmians, like the Sogdians, mourned the dead, as demonstrated by the paintings on the Toprak-Kala ossuaries. Veneration of the dead was highly esteemed in Khwarazm, with food being placed in the burial chambers on the last five days of the last (twelfth) month and five extra days during the New Year. The local cult of Vakhsh—the tutelary spirit of the element of water—was a sign of early animism amongst the Khwarazmians. They commemorated the feast of Vakhsh on the tenth day of the last month of the year.
 The native language of Afrighid Khwarazm was Old Khwarazmian, written an indigenous script derived from Aramaic, which had been imported by the Achaemenid Empire (550–330 BC) during their rule over Khwarazm. According to the 10th-century Arab traveller Ahmad ibn Fadlan, the language sounded "like the chattering of starlings."
 Only consonants of the pre-Islamic names are known with long vowels, since in Arabic script, the short vowels are not written and diacritic signs are used to clarify when required. After the conversion of 'Abdallah, all the names except possibly 'Eraq are Arabic and their pronunciation is known. Unfortunately, the manuscripts that have also come down have also suffered some corruption due to scribal errors, since the Khwarezmian names were incomprehensible for most non-natives. Al-Biruni himself utilizes the extra letters of Khwarezmian which were not used in Arabic writings.
 More is known about the dynasty in the Islamic era after the beginning of the 8th century and their conversion to Islam.
 Name of the rulers given by the native Khwarezmian speaker Al-Biruni, and modern scholars.