Hagia Sophia was a church from 365 AD to 1453, when it was converted to a mosque by an Ottomen Sultan.
Hagia Sophia (/ˈhɑːɪə soʊˈfiːə/; from the Greek: Ἁγία Σοφία [aˈʝia soˈfia], “Holy Wisdom“; Latin: Sancta Sophia or Sancta Sapientia; Turkish: Ayasofya) is a former Orthodox patriarchal basilica, later a mosque, and now a museum in Istanbul, Turkey. From the date of its dedication in 360 until 1453, it served as an Eastern Orthodox cathedral and seat of the Patriarchate of Constantinople, except between 1204 and 1261, when it was converted to a Roman Catholic cathedral under the Latin Empire. The building was a mosque from 29 May 1453 until 1931, when it was secularized. It was opened as a museum on 1 February 1935.
The Church was dedicated to the Logos, the second person of the Holy Trinity, its dedication feast taking place on 25 December, the anniversary of the Birth of the incarnation of the Logos in Christ. Although it is sometimes referred to as Sancta Sophia (as though it were named after Saint Sophia), sophia is the phonetic spelling in Latin of the Greek word for wisdom – the full name in Greek being Ναός τῆς Ἁγίας τοῦ Θεοῦ Σοφίας, “Shrine of the Holy Wisdom of God”.
Famous in particular for its massive dome, it is considered the epitome of Byzantine architecture and is said to have “changed the history of architecture.” It remained the world’s largest cathedral for nearly a thousand years thereafter, until Seville Cathedral was completed in 1520. The current building was originally constructed as a church between 532 and 537 on the orders of the Byzantine Emperor Justinian and was the third Church of the Holy Wisdom to occupy the site, the previous two having both been destroyed by rioters. It was designed by the Greek scientists Isidore of Miletus, a physicist, and Anthemius of Tralles, a mathematician.
The church contained a large collection of holy relics and featured, among other things, 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 on the part of Pope Leo IX in 1054, an act which is commonly considered the start of the Great Schism.
In 1453, Constantinople was conquered by the Ottoman Turks under Sultan Mehmed II, who subsequently ordered the building converted into a mosque. The bells, altar, iconostasis, and sacrificial vessels were removed and many of the mosaics were plastered over. Islamic features – such as the mihrab, minbar, and four minarets – were added while in the possession of the Ottomans. 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.
For almost 500 years the principal mosque of Istanbul, Hagia Sophia served as a model for many other Ottoman mosques, such as the Sultan Ahmed Mosque (Blue Mosque of Istanbul), the Şehzade Mosque, the Süleymaniye Mosque, the Rüstem Pasha Mosque and the Kılıç Ali Paşa Mosque.
Source : http://en.wikipedia.org/wiki/Hagia_Sophia#First_church