Hagia Sophia (; from Koinē Greek: Ἁγία Σοφία, romanized: Hagía Sophía; Latin: Sancta Sophia, lit. 'Holy Wisdom'), officially the Hagia Sophia Holy Grand Mosque (Turkish: Ayasofya-i Kebir Cami-i Şerifi) and formerly the Church of Hagia Sophia, is a Late Antique place of worship in Istanbul. 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 Roman Catholic cathedral. In 1453, after the Fall of Constantinople to the Ottoman Empire, it was converted into a mosque. In 1935 the secular Turkish Republic established it as a museum. In 2020, it re-opened as 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 building was designed by the Greek geometers Isidore of Miletus and Anthemius of Tralles. The present Justinianic building was the third church of the same name to occupy the site, the prior one having been destroyed in the Nika riots. Being 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 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 sometimes referred to as Sancta Sophia, 'Saint Sophia', it is not connected with Sophia the Martyr. The centre of the Eastern Orthodox Church for nearly one thousand years, the building witnessed the excommunication of Patriarch Michael I Cerularius officially delivered by Humbert of Silva Candida, the papal 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 Roman 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). From its initial conversion until the construction in 1616 of the nearby Sultan Ahmed Mosque, aka the Blue Mosque, it was the principal mosque of Istanbul. The Byzantine architecture of the Hagia Sophia served as inspiration for many other religious buildings from the Hagia Sophia, Thessaloniki and Panagia Ekatontapiliani to the Blue Mosque, 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 by 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, invoking condemnation from the Turkish opposition, UNESCO, the World Council of Churches, the International Association of Byzantine Studies, and many international leaders.