President Tayyip Erdogan declared Istanbul's Hagia Sophia open to Muslim prayer as a mosque on Friday after a top court ruled that the ancient building's conversion to a museum by modern Turkey's founding statesman was illegal.
Erdogan made his announcement just an hour after the court ruling was published, brushing aside international warnings not to change the status of the nearly 1,500-year-old monument that is revered by Christians and Muslims alike.
The United States, Russia and church leaders were among those to express concern about changing the status of the UNESCO World Heritage Site, a focal point of both the Christian Byzantine and Muslim Ottoman empires and now one of the most visited monuments in Turkey.
Greece's culture ministry described the court decision as an "open provocation" to the civilized world.
Erdogan has sought to shift Islam into the mainstream of Turkish politics in his 17 years at the helm. He has long proposed restoring the mosque status of the sixth-century building, which was converted into a museum in the early days of the modern secular Turkish state under Mustafa Kemal Ataturk.
"The decision was taken to hand over the management of the Ayasofya Mosque. ..to the Religious Affairs Directorate and open it for worship," the decision signed by Erdogan said.
The Council of State, Turkey's top administrative court, said in its ruling: "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, referring to an edict signed by Ataturk.
The association which brought the court case, the latest in a 16-year legal battle, said Hagia Sophia was the property of the Ottoman leader who captured the city in 1453 and turned the already 900-year-old Greek Orthodox cathedral into a mosque.
The Ottomans built minarets alongside the vast domed structure, while inside they added panels bearing the Arabic names of God, the Prophet Mohammad, and Muslim caliphs. The golden mosaics and Christian icons, obscured by the Ottomans, were uncovered again when Hagia Sophia became a museum.
Erdogan, a pious Muslim, threw his weight behind the campaign before local elections last year which dealt a painful blow to his ruling Islamist-rooted AK Party. He was due to speak shortly before 9 p.m. (1800 GMT).
Hundreds of people gathered near Hagia Sophia celebrating the ruling. "Those who built this did it to worship God as well," said Osman Sarihan, a teacher.
"Thank God today it reverted to its main purpose. Today God will be worshipped in this mosque."
In parliament in Ankara, AK Party members stood and applauded after Erdogan's decree was read aloud.
By reversing one of Ataturk's most symbolic steps, which underlined the former leader's commitment to a secular republic, Erdogan has capped his own project to restore Islam in public life, said Soner Cagaptay, director of the Turkish Research Program at the Washington Institute for Near East Policy.
"Hagia Sophia is the crowning moment of Erdogan's religious revolution which has been unfolding in Turkey for over a decade," he said, pointing to greater emphasis on religion in education and across government.
The Russian Orthodox Church said it regretted that the court did not take its concerns into account when making its ruling and said the decision could lead to even greater divisions, the TASS news agency reported. UNESCO also expressed regret at the move.
Previously, Ecumenical Patriarch Bartholomew, the spiritual head of some 300 million Orthodox Christians worldwide and based in Istanbul, said converting it into a mosque would disappoint Christians and would "fracture" East and West.
US Secretary of State Mike Pompeo had also urged Turkey to maintain the building as a museum.
But Turkish groups have long campaigned for Hagia Sophia's conversion, saying it would better reflect Turkey's status as an overwhelmingly Muslim country.