linguistic:paraphrasing, stylistic:style_transfer
Mosque (1453–1935)

Constantinople fell to the attacking Ottoman forces on 29 May 1453. Sultan Mehmed II entered the city and performed the Friday prayer and khutbah (sermon) in Hagia Sophia, and this action marked the official conversion of Hagia Sophia into a mosque. The church's priests and religious personnel continued to perform Christian rites, prayers, and ceremonies until they were compelled to stop by the invaders. When Mehmed and his entourage entered the church, he ordered that it be converted into a mosque immediately. One of the ʿulamāʾ (Islamic scholars) present climbed onto the church's ambo and recited the shahada ("There is no god but Allah, and Muhammad is his messenger"), thus marking the beginning of the conversion of the church into a mosque. Mehmed is reported to have taken a sword to a soldier who tried to pry up one of the paving slabs of the Proconnesian marble floor.

As described by Western visitors before 1453, such as the Córdoban nobleman Pero Tafur and the Florentine geographer Cristoforo Buondelmonti, the church was in a dilapidated state, with several of its doors fallen from their hinges. Mehmed II ordered a renovation of the building. Mehmed attended the first Friday prayer in the mosque on 1 June 1453. Aya Sofya became the first imperial mosque of Istanbul. Most of the existing houses in the city and the area of the future Topkapı Palace were endowed to the corresponding waqf. From 1478, 2,360 shops, 1,300 houses, 4 caravanserais, 30 boza shops, and 23 shops of sheep heads and trotters gave their income to the foundation. Through the imperial charters of 1520 (AH 926) and 1547 (AH 954), shops and parts of the Grand Bazaar and other markets were added to the foundation.

Before 1481, a small minaret was erected on the southwest corner of the building, above the stair tower. Mehmed's successor Bayezid II (r. 1481–1512) later built another minaret at the northeast corner. One of the minarets collapsed after the earthquake of 1509, and around the middle of the 16th century they were both replaced by two diagonally opposite minarets built at the east and west corners of the edifice. In 1498, Bernardo Bonsignori was the last Western visitor to Hagia Sophia to report seeing the ancient Justinianic floor; shortly afterwards the floor was covered over with carpet and not seen again until the 19th century.

In the 16th century, Sultan Suleiman the Magnificent (r. 1520–1566) brought two colossal candlesticks from his conquest of the Kingdom of Hungary and placed them on either side of the mihrab. During Suleiman's reign, the mosaics above the narthex and imperial gates depicting Jesus, Mary, and various Byzantine emperors were covered by whitewash and plaster, which were removed in 1930 under the Turkish Republic.

During the reign of Selim II (r. 1566–1574), the building started showing signs of fatigue and was extensively strengthened with the addition of structural supports to its exterior by Ottoman architect Mimar Sinan, who was also an earthquake engineer. In addition to strengthening the historic Byzantine structure, Sinan built two additional large minarets at the western end of the building, the original sultan's lodge and the türbe (mausoleum) of Selim II to the southeast of the building in 1576–1577 (AH 984). In order to do that, parts of the Patriarchate at the south corner of the building were pulled down the previous year. Moreover, the golden crescent was mounted on the top of the dome, and a respect zone 35 arşın (about 24 m) wide was imposed around the building, leading to the demolition of all houses within the perimeter. The türbe became the location of the tombs of 43 Ottoman princes. Murad III (r. 1574–1595) imported two large alabaster Hellenistic urns from Pergamon (Bergama) and placed them on two sides of the nave.

In 1594 (AH 1004) Mimar (court architect) Davud Ağa built the türbe of Murad III, where the Sultan and his valide, Safiye Sultan were buried. The octagonal mausoleum of their son Mehmed III (r. 1595–1603) and his valide was built next to it in 1608 (AH 1017) by royal architect Dalgiç Mehmet Aĝa. His son Mustafa I (r. 1617–1618, 1622–1623) converted the baptistery into his türbe.

In 1717, under the reign of Sultan Ahmed III (r. 1703–1730), the crumbling plaster of the interior was renovated, contributing indirectly to the preservation of many mosaics, which otherwise would have been destroyed by mosque workers. In fact, it was usual for the mosaic's tesserae —believed to be talismans —to be sold to visitors. Sultan Mahmud I ordered the restoration of the building in 1739 and added a medrese (a Koranic school, subsequently the library of the museum), an imaret (soup kitchen for distribution to the poor) and a library, and in 1740 he added a Şadirvan (fountain for ritual ablutions), thus transforming it into a külliye, or social complex. At the same time, a new sultan's lodge and a new mihrab were built inside.