After an earthquake, Trdat the Architect finished rebuilding it again in 994. It was used as an Eastern Orthodox church until 1453, except when it was the Roman Catholic cathedral between 1204 and 1261. The Ottoman sultan and caliph Mehmed the Conqueror converted Hagia Sophia into a mosque in 1453 after the Fall of Constantinople.