A top Turkish administrative court has revoked the Byzantine-era Hagia Sophia's status as a museum, clearing the way for it to be turned back into a mosque, Turkey's state-run news agency reported on Friday.
The Council of State, which was debating a case brought by a Turkish NGO, cancelled a 1934 cabinet decision and ruled the UNESCO World Heritage site would be reopened to Muslim worshipping.
The Council of State threw its weight behind a petition brought by a religious group and annulled a 1934 cabinet decision that changed the 6th century building into a museum. The ruling allows the government to restore the Hagia Sophia's previous status as a mosque.
Turkish President Recep Tayyip Erdoğan had proposed restoring the mosque 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.
Dozens of people who awaited the court's ruling outside the Hagia Sophia jubilantly chanted "Allah is great!" when the news came out.
The Turkish NGO had contested the legality of the 1934 decision by the modern Turkish republic's secular government ministers and argued that the building was the personal property of Ottoman Sultan Mehmet II, who conquered Istanbul in 1453.
The court ruled that Hagia Sophia was the property of a foundation managing the Sultan's assets and was opened up to the public as a mosque.
Under the Byzantine Empire, Hagia Sophia had been used as a church for 916 years. In 1453, after the Ottoman Empire conquered Istanbul, it was converted into a mosque by Sultan Mehmet II.
An unparalleled treasure of world architecture, Hagia Sophia underwent restoration work during the Ottoman era, including the addition of minarets for the call to prayer by famed architect Mimar Sinan.
Under the Turkish Republic, it became a museum in 1935.
In recent years Turkish leaders have called for its use as a mosque again and allowed Quran recitations there on special occasions.