Prior to Islam, the Khwarezm region was ruled by the Afrighid dynasty. These were Iranian Zoroastrians, who served as vassals to the Samanids They were highly cultured, and tolerant of their Muslim subjects. The historian Al-Biruni was a product of their court. In 995 C.E., they were overthrown by some mysterious and opportunistic Muslim "traders" of Iranian origin, who created the Mamunid dynasty.