Hagia Sophia (Turkish: Ayasofya; Koinē Greek: Ἁγία Σοφία, romanized: Hagía Sophía; Latin: Sancta Sophia, lit. 'Holy Wisdom'), officially known as the Holy Hagia Sophia Grand Mosque (Turkish: Ayasofya-i Kebir Cami-i Şerifi, آياصوفيا كبير جامع شريف), and formerly the Church of Hagia Sophia (Turkish: Ayasofya Kilisesi; Greek: Ναός της Αγίας του Θεού Σοφίας, romanized: Naós tis Ayías tou Theoú Sofías; Latin: Ecclesia Sanctae Sophiae) 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 became the city's Latin Catholic cathedral. In 1453, after the Fall of Constantinople to the Ottoman Empire, it was converted into a mosque. In 1935, the secular Republic of Turkey established it as a museum. In 2020, it was re-converted into a mosque during the administration of President Recep Tayyip Erdoğan.
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 church was dedicated to the Holy Wisdom, the Logos, the second person of the Trinity. Its patronal feast falls on 25 December (Christmas), the commemoration of the incarnation of the Logos in Christ. Sophia is the Latin transliteration of the Greek word for wisdom, and, although it is sometimes referred to as Sancta Sophia, 'Saint Sophia', it is not related to Sophia the Martyr. The centre of the Eastern Orthodox Church for nearly one thousand years, 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 that is commonly considered the start of the East–West Schism. In 1204, it was converted by the Fourth Crusaders to a Latin Catholic cathedral under the Latin Empire, before being restored to the Eastern Orthodox Church upon the return 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. The patriarchate moved to the Church of the Holy Apostles, which became the city's cathedral. Although some parts of the city had fallen into disrepair, the cathedral had been maintained with funds set aside for this purpose, and the Christian cathedral made a strong impression on the new Ottoman rulers who conceived its conversion. The bells, altar, iconostasis, ambo, and baptistery were removed and relics destroyed. The mosaics depicting Jesus, his mother Mary, Christian saints, and angels were eventually destroyed or plastered over. Islamic architectural features were added, such as a minbar (pulpit), four minarets, and a mihrab – a niche indicating the direction of prayer (qibla). It was the principal mosque of Istanbul from its initial conversion until the 1616 construction of the nearby Sultan Ahmed Mosque (the Blue Mosque). 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 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. According to data released by the Ministry of Culture and Tourism, Hagia Sophia was Turkey's most visited tourist attraction in 2015 and 2019.In early July 2020, the Council of State annulled the Cabinet's 1934 decision to establish the museum, revoking the monument's status, and a subsequent decree by Turkish president Recep Tayyip Erdoğan ordered the reclassification of Hagia Sophia 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 is controversial, drawing condemnation from the Turkish opposition, UNESCO, the World Council of Churches, the International Association of Byzantine Studies, and many international leaders.