ANKARA, Turkey (AP) — The president of Turkey on Friday formally converted Istanbul’s sixth-century Hagia Sophia back into a mosque and declared it open for Muslim worship, hours after a high court annulled a 1934 decision that had made the religious landmark a museum.

The decision sparked deep dismay among Orthodox Christians. Originally a cathedral, Hagia Sophia was turned into a mosque after Istanbul’s conquest by the Ottoman Empire but had been a museum for the last 86 years, drawing millions of tourists annually.

There was jubilation outside the terracotta-hued structure with its cascading domes and four minarets. Dozens of people awaiting the court’s ruling chanted “Allah is great!” when the news broke. A large crowd later prayed outside it.

TURKEY ISSUES PRESIDENTIAL DECREE TO CONVERT HAGIA SOPHIA BACK INTO MOSQUE

In the capital of Ankara, legislators stood and applauded as the decision was read in Parliament.

Turkey’s high administrative court threw its weight behind a petition brought by a religious group and annulled the 1934 Cabinet decision that turned the site into a museum. Within hours, President Recep Tayyip Erdogan signed a decree handing over Hagia Sophia to Turkey’s Religious Affairs Presidency.

In a televised address to the nation, Erdogan said the first prayers inside Hagia Sofia would be held on July 24, and he urged respect for the decision.

“I underline that we will open Hagia Sophia to worship as a mosque by preserving its character of humanity’s common cultural heritage,” he said, adding: “It is Turkey’s sovereign right to decide for which purpose Hagia Sofia will be used.”

He rejected the idea that the decision ends Hagia Sophia’s status as a structure that brings faiths together.

“Like all of our other mosques, the doors of Hagia Sophia will be open to all, locals or foreigners, Muslims and non-Muslims,” Erdogan said.

AT LEAST TWO DEAD, DOZENS INJURED AS EXPLOSION ROCKS TURKISH FIREWORKS FACTORY

Erdogan had spoken in favor of turning the hugely symbolic UNESCO World Heritage site back into a mosque despite widespread international criticism, including from U.S. and Orthodox Christian leaders, who had urged Turkey to keep its status as a museum symbolizing solidarity among faiths and cultures.

The decision threatens to deepen tensions with neighboring Greece, whose culture minister, Lina Mendoni, denounced the move as “an open challenge to the entire civilized world that recognizes the unique value and universality of the monument.”

In Greece’s second-largest city, Thessaloniki, protesters gathered outside a church that is modeled on Hagia Sophia and bears the same name. They chanted, “We’ll light candles in Hagia Sophia!” and held Greek flags and Byzantine banners.

Cyprus “strongly condemns Turkey’s actions on Hagia Sophia in its effort to distract domestic opinion and calls on Turkey to respect its international obligations,” tweeted Foreign Minister Nikos Christodoulides.

Vladimir Dzhabarov, deputy head of the foreign affairs committee in the Russian upper house of parliament, called the action “a mistake.”

“Turning it into a mosque will not do anything for the Muslim world. It does not bring nations together, but on the contrary brings them into collision,” he said.

The debate hits at the heart of Turkey’s religious-secular divide. Nationalist and conservative groups in Turkey have long yearned to hold prayers at Hagia Sophia, which they regard as part of the Muslim Ottoman legacy. Others believe it should remain a museum, as a symbol of Christian and Muslim solidarity.

“It was a structure that brought together both Byzantine and Ottoman histories,” said Zeynep Kizildag, a 27-year-old social worker, who did not support the conversion. “The decision to turn it into a mosque is like erasing 1,000 years of history, in my opinion.”

Garo Paylan, an ethnic Armenian member of Turkey’s Parliament tweeted that it was “a sad day for Christians (and) for all who believe in a pluralist Turkey.”

“The decision to convert Hagia Sophia into a mosque will make life more difficult for Christians here and for Muslims in Europe,” he wrote. “Hagia Sophia was a symbol of our rich history. Its dome was big enough for all.”

The group that brought the case to court had contested the legality of the 1934 decision by the modern Turkish republic’s secular government ministers, arguing the building was the personal property of Ottoman Sultan Mehmet II, who conquered Istanbul in 1453.

“I was not surprised at all that the court weighed to sanction Erdogan’s moves because these days Erdogan gets from Turkish courts what Erdogan wants,” said Soner Cagaptay, of the Washington Institute.

“Erdogan wants to use Hagia Sophia’s conversion into a mosque to rally his right-wing base,” said Cagaptay, the author of “Erdogan’s Empire.” “But I don’t think this strategy will work. I think that short of economic growth, nothing will restore Erdogan’s popularity.”

CLICK HERE TO GET THE FOX NEWS APP

In Paris, the United Nations cultural body, UNESCO, said it deeply regretted the decision.

“Its status as a museum reflects the universal nature of its heritage, and makes it a powerful symbol for dialogue,” said Director-General Audrey Azoulay.

The Istanbul-based Ecumenical Patriarch Bartholomew I, considered the spiritual leader of the world’s Orthodox Christians, warned last month that the building’s conversion into a mosque “will turn millions of Christians across the world against Islam.”

Patriarch Kirill, the leader of the Russian Orthodox Church, called for “prudence” and the preservation of the “current neutral status” for the Hagia Sophia, which he said was one of Christianity’s “devoutly venerated symbols.”

U.S. State Secretary Mike Pompeo said last month the landmark should remain a museum to serve as bridge between faiths and cultures. His comments sparked a rebuke from Turkey’s Foreign Ministry, which said Hagia Sophia was a domestic issue of Turkish national sovereignty.

Erdogan, a devout Muslim, has frequently used the Hagia Sophia issue to drum up support for his Islamic-rooted party.

Some Islamic prayers have been held in the museum in recent years. In a major symbolic move, Erdogan recited the opening verse of the Quran there in 2018.

Built under Byzantine Emperor Justinian, Hagia Sophia was the main seat of the Eastern Orthodox church for centuries, where emperors were crowned amid ornate marble and mosaic decorations.

The minarets were added later and the building was turned into an imperial mosque following the 1453 Ottoman conquest of Constantinople — the city that is now called Istanbul.

The building opened its doors as a museum in 1935, a year after the Council of Ministers’ decision.

Mosaics depicting Jesus, Mary and Christian saints that were plastered over in line with Islamic rules were uncovered through arduous restoration work for the museum. Hagia Sophia was the most popular museum in Turkey last year, drawing more than 3.7 million visitors.

Associated Press writers Zeynep Bilginsoy and Ayse Wieting in Istanbul, Derek Gatopoulos in Athens, Menelaos Hadjicostis in Nicosia, Cyprus, and Jim Heintz in Moscow contributed.