A Turkish court has annulled the museum status of Hagia Sophia in Istanbul, a world-famous cultural site, enabling it to be converted into a mosque.
It is a controversial move, as 1,500-year-old Hagia Sophia was founded as a cathedral, the BBC reported.
Later the Ottomans made it a mosque. In 1934 it became a museum.
It is a Unesco World Heritage site. Unesco earlier urged Turkey not to change its status without discussion.
Turkey's President Recep Tayyip Erdogan called for the change.
Islamists in Turkey have long called for it to be converted to a mosque, but secular opposition members have opposed the move. The proposal has prompted criticism, from religious and political leaders worldwide.
The head of the Eastern Orthodox Church has condemned the proposal, as has Greece – home to many millions of Orthodox followers.
Modern Turkey's founder Mustafa Kemal Ataturk approved Hagia Sophia's status as a museum in 1934, and since then it has been a symbol of secularism, open to all faiths.
But the Council of State, Turkey's top administrative court, said in its ruling on Friday: "It was concluded that the settlement deed allocated it as a mosque and its use outside this character is not possible legally".
"The cabinet decision in 1934 that ended its use as a mosque and defined it as a museum did not comply with laws," it said.
The Russian Orthodox Church immediately expressed regret that the Turkish court did not take its concerns into account when ruling on Hagia Sophia, Tass news agency reported.
It said the decision could lead to even greater divisions.