Shortly after the ruling, President Erdogan signed a decree opening Istanbul's Hagia Sophia for prayers and transferring the monument to the presidency of religious affairs.
Turkey’s top administrative court has ruled the 1934 conversion of Hagia Sophia into a museum was illegal, paving the way for the monument to be reopened for prayers.
The case had been brought by a Turkish NGO seeking an annulment of the decision to convert Hagia Sophia into a museum after being a mosque for nearly 500 years, a move backed by Turkey's President Recep Tayyip Erdogan.
Shortly after the ruling, Erdogan signed a decree opening Istanbul's Hagia Sophia for prayers.
Erdogan shared on his Twitter feed a copy of the decree he had signed which said the decision had been taken to hand control of the Ayasofya Mosque, as it is known in Turkish, to the country's religious directorate and reopen it for worship.
The Council of State ruled that since the Hagia Sophia is owned by the Fatih Sultan Mehmet Han Foundation, it's status on the deed is listed as a mosque and cannot be changed. The council reasoned Ottoman Sultan Mehmet II, who conquered Istanbul, deemed the property to be used by the public as a mosque without any fees and was not within the jurisdiction of the Parliament or a ministry council.
The Council of Ministers' decision to turn the mosque into a museum was made in 1934, in the early years of the modern secular Turkish state founded by Mustafa Kemal Ataturk.
The lawyer of the group seeking to convert the iconic edifice back into a mosque argued that the building was the personal property of Ottoman Sultan Mehmet II.
A state attorney, meanwhile, argued that the 1934 decision was legal.
He recommended the request be rejected, arguing that a decision on restoring the structure's Islamic heritage was up to the government, the agency said.
Hagia Sophia will always be part of global historical heritage
Reopening Istanbul’s Hagia Sophia for prayers will not deprive it of its identity, as it will always belong to the world’s historical heritage, Ibrahim Kalin, Turkey’s presidential spokesperson, said this week.
Such a move will not hinder people visiting it, he said.
Turkey will still preserve Christian icons there, just like our ancestors preserved all Christian values, said Kalin.
“All of our major mosques such as the Blue Mosque, Fatih and Suleymaniye Mosques, they are open to both visitors and worshippers," Kalin said.
Kalin cited the examples of France’s iconic Notre Dame Cathedral and Sacre-Coeur Basilica, world-famous churches which are open to both tourists and worshippers.
“Opening up Hagia Sophia to worship doesn't keep local or foreign tourists from visiting the site,” Kalin stressed.
“So a loss from the world’s heritage is not in question,” he added.
Erdogan last week said that accusations against the country about Hagia Sophia directly target its sovereignty, adding that Turkey will always protect the rights of Muslims and the minorities living in the country.
The sixth-century edifice – whose stunning architecture is a magnet for tourists worldwide – has been a museum since 1935, open to all.
Hagia Sophia was first constructed as a church during the Christian Byzantine Empire but was converted into a mosque after the Ottoman conquest of Constantinople in 1453.
Turning it into a museum was a key reform of the post-Ottoman authorities under the modern republic's founder Mustafa Kemal Ataturk.
But calls for it to serve again as a mosque have sparked tensions between the historic foes and uneasy NATO allies Turkey and Greece.
Russia, which has become an increasingly important partner of Turkey in recent years, has also urged against altering its status.