Turkish President Recep Tayyip Erdogan announced Friday that Istanbul’s iconic Hagia Sophia would become a mosque once again, brushing aside a legacy of Turkey’s secularizing modern founder, who converted the site to a museum more than eight decades ago.

In a televised address, Erdogan said that prayers would start at the compound in two weeks and that Hagia Sophia — originally a Byzantine Christian cathedral and later an Ottoman mosque — would remain open and accessible to visitors from all over the world.

“We will open Hagia Sophia to worship as a mosque, preserving the common cultural heritage of humanity,” he said. Entrance to the site, he added, would be free of charge.

Critics have argued that converting the monument would be religiously divisive and diminish its appeal as a destination for people of all faiths. Some of the loudest warnings came from abroad, including from the United States and Greece, which is largely Orthodox Christian.

Stelios Petsas, a spokesman for the Greek government, said this month that converting Hagia Sophia would be “a huge emotional chasm between the Christians of the world and Turkey,” according to the Reuters news agency. Secretary of State Mike Pompeo had also urged Turkey to maintain Hagia Sophia as a museum, saying it served as a “much-needed bridge between those of differing faith traditions and cultures.”

The State Department on Friday said it was “disappointed” by Turkey’s decision.

“We understand the Turkish Government remains committed to maintaining access to the Hagia Sophia for all visitors and look forward to hearing its plans for continued stewardship of the Hagia Sophia to ensure it remains accessible without impediment for all,” State Department spokeswoman Morgan Ortagus said in a statement.

The building, commissioned by the Byzantine Emperor Justinian I and designed by architects Anthemius of Tralles and Isidore of Miletus, was inaugurated in 537 and for centuries stood as the largest church in the Christian world, with a dome that soared more than 160 feet off the floor.

It was converted into a mosque in 1453, when the Ottomans conquered Istanbul, with minarets placed around its perimeter, its Byzantine mosaics covered in whitewash. Mustafa Kemal Ata­turk, the founder of the modern Turkish republic, transformed it into a museum in 1934. It was the most visited museum in Turkey last year, drawing 3.7 million visitors, according to the website of Istanbul’s governor.

A decision Friday by Turkey’s top administrative court reversed Hagia Sophia’s designation as a museum and restored it as a mosque — a victory for Muslim religious conservatives and nationalists in Turkey who for years had pushed to reclassify the monument.

But they received additional support this time from Erdogan, whose focus on the “resurrection” of Hagia Sophia, as he put it on Friday, was seen by many as an attempt to whip up political support from his base of supporters as his broader popularity wanes.

In his speech, Erdogan tied his decision to the grandeur of Turkey’s Ottoman past and nurtured a sense of grievance for his conservative audience: devout Muslims like himself.

“If there is going to be a debate focused on religion, then the subject shouldn’t be the Hagia Sophia but of Islamophobia and xenophobia across the world,” he said.

And while he acknowledged the criticism from abroad, he said that “the use of the Hagia Sophia concerns our country’s sovereignty.”

“I invite everyone to respect the decision,” he said.

Supporters of the move gathered outside Hagia Sophia on Friday evening, waving Turkish flags before holding prayers.

“Its status as a mosque takes away nothing from its world cultural heritage,” Ibrahim Kalin, an adviser to Erdogan, wrote on Twitter. “All are welcome to visit this beautiful house of worship and magnificent cultural site.”

UNESCO, in a statement Friday, noted that Hagia Sophia’s inclusion on the World Heritage List as a museum meant that the state “must ensure that no modification is made to the outstanding universal value of the property inscribed on its territory.”

“Any modification requires prior notification by the State concerned to UNESCO and then, if necessary, examination by the World Heritage Committee,” the statement added. “We call upon the Turkish authorities to engage in dialogue before taking any decision that might impact the universal value of the site.”

As momentum built for the conversion of the site in recent weeks, many questioned why the status of Hagia Sophia was a priority at a time when Turkey is wrestling with the novel coronavirus and the economic consequences of the worldwide pandemic.

“This is a world legacy, a magnificent work,” Ekrem Imamoglu, the mayor of Istanbul and a member of Turkey’s largest opposition party, said in an interview last month. “What is the need to open this debate now, when 97 percent of tourism has frozen, while hotels are closed, while tourism has plummeted and hundreds of thousands of people have become unemployed?”

“This is not on the agenda for Turkey. Is this our issue right now?”

Carol Morello contributed to this report.