Hagia Sophia (; from the Greek 'Αγία Σοφία, pronounced [haˈʝia soˈfia], "Holy Wisdom"; Latin: Sancta Sophia or Sancta Sapientia; Turkish: Ayasofya) is the former Greek Orthodox Christian patriarchal cathedral, later an Ottoman imperial mosque and now a museum (Ayasofya Müzesi) in Istanbul, Turkey. Built in AD 537 in the Late Antiquity, it is famous for its massive dome. It was the world's largest building and an engineering marvel of its time. It is considered the epitome of Byzantine architecture and is said to have "changed the history of architecture".The Hagia Sophia is of masonry construction. The structure has brick and mortar joints that are 1.5 times the width of the bricks. The mortar joints are composed of a combination of sand and minute ceramic pieces distributed evenly throughout the mortar joints. This combination of sand and ceramic pieces could be considered the contemporaneous equivalent of modern concrete.From the date of its completion in 537 until 1453, it served as an Eastern Orthodox cathedral and the seat of the ecumenical patriarch of Constantinople, except between 1204 and 1261, when it was converted by the Fourth Crusaders to a Roman Catholic cathedral under the Latin Empire. The building was later converted into an Ottoman mosque from 29 May 1453 until 1931. It was then secularized and opened as a museum on 1 February 1935. It remained the world's largest cathedral for nearly a thousand years, until Seville Cathedral was completed in 1520.
The building was constructed between 532 and 537 on the orders of the Byzantine emperor Justinian I as the third Church of the Holy Wisdom to occupy the site, the prior one having been destroyed by rioters in the Nika riots. It was designed by the Greek geometers Isidore of Miletus and Anthemius of Tralles. The church was dedicated to the Wisdom of God, the Logos, the second person of the Trinity, its patronal feast taking place on 25 December, the commemoration of the birth of the incarnation of the Logos in Christ. Although sometimes referred to as Sancta Sophia (as though it were named after Sophia the Martyr), sophia is the phonetic spelling in Latin of the Greek word for wisdom. Its full name in Greek is Ναός της Αγίας του Θεού Σοφίας, Naos tēs Hagias tou Theou Sophias, "Shrine of the Holy Wisdom of God". The church housed a large collection of relics and featured a 15-metre (49 ft) silver iconostasis. The focal point of the Eastern Orthodox Church for nearly one thousand years, the building witnessed the excommunication of Patriarch Michael I Cerularius officially communicated 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 1453, Constantinople was conquered by the Ottoman Empire under Mehmed the Conqueror, who ordered this main church of Eastern Orthodox Christianity converted into a mosque. Although some parts of the city of Constantinople 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, and other relics were destroyed and the mosaics depicting Jesus, his mother Mary, Christian saints, and angels were eventually destroyed or plastered over. Islamic features – such as the mihrab (a niche in the wall indicating the direction toward Mecca, for prayer), minbar (pulpit), and four minarets – were added. It 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 Republic of Turkey. Hagia Sophia was, as of 2014, the second-most visited museum in Turkey, attracting almost 3.3 million visitors annually. According to data released by the Turkish Culture and Tourism Ministry, Hagia Sophia was Turkey's most visited tourist attraction in 2015 and 2019.From its initial conversion until the construction of the nearby Sultan Ahmed Mosque, aka the Blue Mosque of Istanbul, in 1616, it was the principal mosque of Istanbul. The Byzantine architecture of the Hagia Sophia served as inspiration for many other Ottoman mosques, including the Blue Mosque, the Şehzade Mosque, the Süleymaniye Mosque, the Rüstem Pasha Mosque and the Kılıç Ali Pasha Complex.