Istanbul, Turkey CNN  — 

Istanbul’s historic Hagia Sophia has reopened for Friday prayers for the first time since a decision was made to turn it back into a mosque after more than 80 years as a museum.

Images on Turkish state television showed crowds of Muslims praying in and around the mosque on Friday morning.

Turkish President Recep Tayyip Erdogan participated in the Friday prayers, where he recited verses of the Quran.

Some people came from outside Istanbul and spent the night around Hagia Sophia waiting for the prayer, according to CNN Turk.

Only 500 people were invited inside the building because of coronavirus restrictions, according to Turkey’s religious affairs director Ali Erbas. Thousands more prayed in the garden and in Sultanahmet Square in Istanbul’s old city.

Worshipers join a prayer program at Hagia Sophia ahead of the first Friday prayers there in 86 years.

Erdogan later visited the Fatih Mosque, where he visited the tomb of Fatih Sultan Mehmet, or Mehmed the Conqueror, who conquered what was then Constantinople in 1453. The city was renamed Istanbul.

The Hagia Sophia was one of the Roman Empire’s first Christian cathedrals, after St. John Lateran in Rome, and is among the best-known Byzantine structures in the world. It switched from a Greek Orthodox cathedral to a mosque after the Ottoman conquest in 1453.

The historic site then became a museum in 1935 as part of a decree by modern Turkey’s secularist founding father Mustafa Kemal Ataturk.

Speaking at Fatih Mosque, Erdogan said Hagia Sophia had returned to its “original” use. “Hopefully it will serve as a mosque until eternity. It is the cultural heritage of all humanity that everybody can come and visit,” he said.

Erdogan ordered the conversion of the historic monument on July 10 after a court annulled a 1934 presidential decree that made it a museum.

The decision, involving one of the city’s most important landmarks and a UNESCO World Heritage site, has been criticized by international religious and political leaders, with UN cultural agency UNESCO among those voicing concern.

However, the move has not prompted wide opposition within Turkey.

The Turkish government has tried to reassure skeptics that the building’s Christian artworks and frescoes will not be touched, with technology instead being used to conceal them during Friday prayers.

Men take part in Friday prayers outside Hagia Sophia in Istanbul on July 24, 2020.

Erdogan has positioned himself as a friend of conservative Islamists in Turkey, moving the country further from its secularist roots.

UNESCO said earlier this month that it deeply regretted Turkey’s decision and that the choice was made without the organization receiving prior notification.

Pope Francis said he was “very saddened” by the building’s conversion. Greece’s culture minister, meanwhile, decried the move as “an open provocation to the entire civilized world.”

Workmen dismantle the Hagia Sophia Museum ticket booth on July 17, 2020 in Istanbul.

Turkish officials have emphasized that when it is not being used as a mosque, the Hagia Sophia – which is popular with tourists visiting Istanbul – will be open to all to visit free of charge, according to state-run news agency Anadolu.

Erdogan used a televised speech on July 10 to urge people to respect the decision to convert the building back to a mosque.

“Like all our mosques, its doors will be open to everyone – Muslim or non-Muslim. As the world’s common heritage, Hagia Sophia with its new status will keep on embracing everyone in a more sincere way,” he said.

“We will be treating every opinion voiced on the international stage with respect. But the way Hagia Sophia will be used falls under Turkey’s sovereign rights. We deem every move that goes beyond voicing an opinion a violation of our sovereignty.”

An earlier version of this story incorrectly identified the Roman Empire’s first cathedral. It was St. John Lateran in Rome.

CNN’s Isil Sariyuce and Arwa Damon reported from Istanbul and Laura Smith-Spark wrote from London. Emma Reynolds contributed to this report.