Mr. Erdogan defended the decision as Turkey’s right and said it represented the will of many Turks. He added that the action of turning it from a mosque into a museum 80 years ago had been illegal, but pledged that the mosque would continue to be open to Muslims and non-Muslims alike.
“Hagia Sophia, the common heritage of humanity, will go forward to embrace everyone with its new status in a much more sincere and much more unique way,’’ he said in a live television address.
Entry to the monument would be free of charge, foregoing the ticket price from several million visitors a year, and the first prayers inside Hagia Sophia will take place on July 24. Just before he spoke, several hundred people gathered outside Hagia Sophia to celebrate a prayer of thanksgiving, recording the call of the muezzin on their phones, and then bent in unison for the evening prayer on the esplanade in front of the building.
Mr. Erdogan may choose to hold prayers only on ceremonial occasions, as he did to mark the anniversary of the Ottoman conquest of the city in May. But his supporters may demand freedom to enter the building for daily prayers.
Conservationists and art historians have raised concerns about what will happen to the medieval mosaics inside Hagia Sophia, which depict the Holy Family and portraits of imperial Christian emperors, which strict Muslims may demand be covered. Tour guides said that the building may be closed to tourists during prayer times, or even that parts of the building be sectioned off to non-Muslims.
A.K.P. party officials suggested holding the first Muslim prayers in Hagia Sophia, or Ayasofya by its Turkish name, on July 15 to mark the anniversary of a failed coup in 2016 against Mr. Erdogan’s government, during a discussion about the change of status in June, the Turkish daily, Hurriyet, reported.
The court decision came as the culmination of a four-year campaign by an obscure cultural association that made legal applications to restore a number of monuments, including several Byzantine churches, as mosques. Hagia Sophia will be the fourth Byzantine church museum to be restored as a mosque under Mr. Erdogan, but by far the most significant one. In November, the famous Chora monastery church in Istanbul had its status as a museum revoked.