Hagia Sophia (Turkish: Ayasofya; Koinē Greek: Ἁγία Σοφία, romanized: Hagía Sophía; Latin: Sancta Sophia, lit. 'Holy Wisdom'), officially known as the Hagia Sophia Grand Mosque (Turkish: Ayasofya-i Kebir Cami-i Şerifi) and formerly as the Church of Holy Wisdom (Greek: Ναός της Αγίας του Θεού Σοφίας, romanized: Naós tis Ayías tou Theoú Sofías), is a Late Antique place of worship in Istanbul, designed by the Greek geometers Isidore of Miletus and Anthemius of Tralles. Built in 537 as the patriarchal cathedral of the imperial capital of Constantinople, it was the largest Christian church of the eastern Roman Empire (the Byzantine Empire) and the Eastern Orthodox Church, except during the Latin Empire from 1204 to 1261, when it temporarily became a Roman Catholic cathedral. In 1453, after the Fall of Constantinople to the Ottoman Empire, it was converted into a mosque. In 1935, the Republic of Turkey established it as a museum. In 2020, it was reconverted into a mosque.
Built by the eastern Roman emperor Justinian I as the Christian cathedral of Constantinople for the state church of the Roman Empire between 532 and 537, the church was then the world's largest interior space and among the first to employ a fully pendentive dome. It is considered the epitome of Byzantine architecture and is said to have "changed the history of architecture". The present Justinianic building was the third church of the same name to occupy the site, as the prior one had been destroyed in the Nika riots. As the episcopal see of the ecumenical patriarch of Constantinople, it remained the world's largest cathedral for nearly a thousand years, until Seville Cathedral was completed in 1520. Beginning with subsequent Byzantine architecture, Hagia Sophia became the paradigmatic Orthodox church form, and its architectural style was emulated by Ottoman mosques a thousand years later. It has been described as "holding a unique position in the Christian world" and as an architectural and cultural icon of Byzantine and Eastern Orthodox civilization.The religious and spiritual centre of the Eastern Orthodox Church for nearly one thousand years, the church was dedicated to the Holy Wisdom. It was where the excommunication of Patriarch Michael I Cerularius was officially delivered by Humbert of Silva Candida, the envoy of Pope Leo IX in 1054, an act considered the start of the East–West Schism. In 1204, it was converted during the Fourth Crusade into a Catholic cathedral under the Latin Empire, before being returned to the Eastern Orthodox Church upon the restoration of the Byzantine Empire in 1261. The doge of Venice who led the Fourth Crusade and the 1204 Sack of Constantinople, Enrico Dandolo, was buried in the church.
After the Fall of Constantinople to the Ottoman Empire in 1453, it was converted to a mosque by Mehmed the Conqueror and became the principal mosque of Istanbul until the 1616 construction of the Sultan Ahmed Mosque. Upon its conversion, the bells, altar, iconostasis, ambo, and baptistery were removed, while iconography, such as the mosaic depictions of Jesus, Mary, Christian saints and angels were removed or plastered over. Islamic architectural additions included four minarets, a minbar and a mihrab. The Byzantine architecture of the Hagia Sophia served as inspiration for many other religious buildings including the Hagia Sophia in Thessaloniki, Panagia Ekatontapiliani, the Şehzade Mosque, the Süleymaniye Mosque, the Rüstem Pasha Mosque and the Kılıç Ali Pasha Complex. The patriarchate moved to the Church of the Holy Apostles, which became the city's cathedral.
The complex remained a mosque until 1931, when it was closed to the public for four years. It was re-opened in 1935 as a museum under the secular Republic of Turkey, and the building was Turkey's most visited tourist attraction in 2015 and 2019.
In July 2020, the Council of State annulled the 1934 decision to establish the museum, and the Hagia Sophia was reclassified as a mosque. The 1934 decree was ruled to be unlawful under both Ottoman and Turkish law as Hagia Sophia's waqf, endowed by Sultan Mehmed, had designated the site a mosque; proponents of the decision argued the Hagia Sophia was the personal property of the sultan. This redesignation drew condemnation from the Turkish opposition, UNESCO, the World Council of Churches, the International Association of Byzantine Studies, and many international leaders.