Khwarazmian dynasty
The Masjid-i Jami of Herat was the city's first congregational mosque. It was built on a site where religious sites had been located for many centuries. The first known building was a Zoroastrian temple converted into a mosque in the 7th century. Afterward, it was enlarged by the Turkic Ghaznavids. In the second half of the 11th century, a Herat mosque was founded under the rule of the Khwarazmian dynasty. It had a wooden roof and was of smaller dimensions than the following buildings. During an earthquake in 1102, it was almost completely destroyed but was rebuilt. Later it was ruined by a fire. Subsequently, the Ghurids constructed a mosque on the existing and adjacent plots.