Erdogan shared the decree on Twitter with the caption “congratulations’’.
It was not immediately clear when the compound, originally built in the 6th century, would be open to Muslim worshippers.
It was founded as a church, later converted into a mosque, and then operated as a secular museum that is a magnet for tourists.
The decree was signed by Erdogan just over an hour after Turkey’s top administrative court overturned an earlier 1934 decree that made the Hagia Sophia a museum.
In justifying its ruling, the court said the Hagia Sophia is actually registered as a mosque and the property of a foundation established by the Ottoman Sultan Mehmed II, who in 1453 captured Istanbul, then known as Constantinople, and turned the already 900-year-old Byzantine church into a mosque.
The court was reviewing a 2016 petition by a little-known association, which argued the Hagia Sophia was the property of Sultan Mehmed II.
It had also argued a signature by Mustafa Kemal Ataturk, the founder of the modern secular Turkish republic, on the 1934 cabinet decision was forged and thus invalid.
“The Council of State has corrected a wrong decision made 86 years ago,’’ the petitioning association’s lawyer, Selami Karaman, told dpa by phone.
The verdict comes as a result of long-standing calls by Turkish Islamic hard-liners to turn the UNESCO heritage site back into a mosque.
The United States, Russia and Greece, along with UNESCO, expressed concern ahead of the ruling.
“The concern of millions of Christians has not been heard,’’ Russian Orthodox Church spokesman, Vladimir Legoida, spoke of Friday’s court ruling, in comments carried by the Russian news agency Interfax.
Erdogan earlier this month rejected international criticism as an “attack” on Turkey’s sovereignty.
Ahead of the decision on Friday, the Police barricaded the area around the Hagia Sophia.
A small group of people chanted Islamic and nationalist slogans, raising their index fingers and shouting “God is Great” behind a police barricade, footage from state news agency Anadolu showed.
The decision could undermine the universal value of the site and trigger a heritage review, UNESCO warned ahead of the court decision.
A cultural landmark for both Christians and Muslims, the Hagia Sophia attracted 3.7 million visitors in 2019, according to Istanbul governor’s office.
The mosque conversion “will disappoint millions of Christians around the world’’, Istanbul-based Patriarch Bartholomew I, the spiritual leader of the Orthodox Christian Church, said in a statement earlier this month.
Karaman said the Hagia Sophia may not be able to be opened for Muslim worship immediately due to logistical issues including covering Christian symbols prohibited in mosques.
Pro-government media recently suggested stretching a curtain over the symbols, among them a well-known mosaic face of an angel uncovered in 2009.
Long a reminder of Turkey’s secular constitution to many with its neutral position, Hagia Sophia hosted an Islamic ceremony accompanied by a call to prayer back in 2016, the first such event in 84 years.
“Hagia Sophia Mosque” hashtag was a trending topic on Turkish Twitter on Friday, with members of the Cabinet also congratulating the conversion.
Lawmakers applauded as they stood up while the parliament speaker read out loud Erdogan’’s order, state broadcaster TRT footage showed.
Leader of main opposition secular Republican People’s Party (CHP), Kemal Kilicdaroglu, earlier this month accused Erdogan of “using as a political tool” the Hagia Sophia issue.
A recent poll by Turkey’s Metropoll found that 44 per cent of Turks believe the government brought Hagia Sophia on the agenda to divert attention from economic troubles.
Turkish media have reported that Islamic prayers could be held there on July 15, the fourth anniversary of a failed coup by a faction in the military.
AFP