The prophet of God in Muslim religion, Muhammad, had prophesied that the first Muslim to pray in Hagia Sophia would go to paradise. Since then, it was a great ambition for Muslim leaders to get Hagia Sophia.

On 29 May 1453, The Sultan of the Ottoman Empire, Mehmet II, conquered Constantinople after a 54 day siege. He directly went to the ancient Byzantine cathedral of Hagia Sophia. When he saw a man hacking the stones of the church and saying that this was a temple for infidels, Mehmet II ordered the looting to be stopped and the church to be converted into a mosque.

With the following years, Sultans added something to the building. Sultan Bayezid ordered a new minaret changing the previous one of his fathers’. In the 16th century, Suleiman the Magnificent brought two colossal candles from Hungary to be placed on both sides of the mihrab. To the end of the 16th century during the reign of Selim II, famous architect Sinan strengthened the building by adding structural supports to its exterior. He also built two minarets on the western end of the building and the mausoleum of Selim II to the southeast of the building. In 1600s, two mausoleums were added next to Selim II’s: Murad III and Mehmed III.

Two restorations were done in Hagia Sophia at the following years. In 1739, during the reign of Mahmud I, a medrese, a kitchen to distribute poor, and a library, and in 1740 a fountain for ritual ablutions were built.