Several thousand Muslims gathered to take part in the first prayer at Hagia Sophia since the Istanbul landmark was reconverted to a mosque, with Turkish President Recep Tayyip Erdogan also in attendance.
President Erdogan and his top ministers, wearing white facemasks as a precaution against COVID-19, knelt on blue carpets at the start of a ceremony.
Earlier, crowds formed at checkpoints around the historic heart of Istanbul where massed police maintained security. Once through the checks, worshippers sat apart on prayer mats in secured areas outside the building in Sultanahmet Square.
The UNESCO World Heritage site in historic Istanbul was first built as a cathedral in the Christian Byzantine Empire but was converted into a mosque after the Ottoman conquest of Constantinople in 1453.
The Council of State, the highest administrative court, on July 10 unanimously cancelled a 1934 decision by modern Turkey's founder Mustafa Kemal Ataturk to turn it into a museum, saying it was registered as a mosque in its property deeds.

The UNESCO World Heritage site in historic Istanbul was first built as a cathedral in the Christian Byzantine Empire. Source: AAP
Mr Erdogan then ordered the building to reopen for Muslim worship, deeply angering the Christian community and further straining relations with NATO ally Greece.
There were Koranic recitations in the morning in Hagia Sophia before the Friday prayer which Erdogan, Turkish officials and foreign dignitaries will attend.
Up to 1,000 people were allowed to pray inside the building. Many more able to pray outside, but faced with such a large flow of people, including some not wearing masks, Istanbul Governor Ali Yerlikaya said the spaces around Hagia Sophia were swiftly filled.
'Provocation'
Experts say Mr Erdogan's move to reconvert Hagia Sophia is an attempt to galvanise his conservative and nationalist base amid economic uncertainty exacerbated by the virus outbreak and some polls suggesting his ruling party is losing votes.
Mr Erdogan's decision has also undone part of the secular legacy of Ataturk, who wanted Hagia Sophia as a museum so as to "offer it to humanity".
The timing of the first prayer is significant. Friday is the 97th anniversary of the Treaty of Lausanne, which set modern Turkey's borders after years of conflict with Greece and Western powers.
Mr Erdogan, who professes nostalgia for the Ottoman empire, has called for the treaty's revision in recent years.
In Turkey, Hagia Sophia remains closely associated with the Ottoman conquest of Constantinople by Sultan Mehmet II, known as the Conqueror.
An Ottoman military band was in the building's forecourt on Friday.
Mr Erdogan shared a video on Twitter on Wednesday which featured Muslims from across the Islamic world singing in tribute to Hagia Sophia.
"You have always been ours, and we are yours," the Turkish leader wrote.
But the Friday prayer is set against a backdrop of tense relations between NATO allies Ankara and Athens, particularly related to Turkish hydrocarbon exploration in the eastern Mediterranean.
Greece strongly denounced the reconversion of Hagia Sophia to a mosque, seeing it as an "open provocation to the entire civilised world."
Preservation concerns
Church bells around Greece will peal at midday on Friday with their flags at half-mast to protest what the head of the Church of Greece, Archbishop Ieronymos, has called an "unholy act of defiling" of the former cathedral.
"(Today) is a day of mourning for all of... Christianity," he said.
Ankara rejects international criticism in the name of "sovereignty" and insists tourists will still be able to visit the mosque and see the mosaics.
Around 3.8 million tourists visited Hagia Sophia last year.
Some experts are concerned about the speed of the conversion as turquoise carpet was laid for the faithful to pray.

Visitors walk inside the Byzantine-era Hagia Sophia, in the historic Sultanahmet district of Istanbul, October 15, 2010. Source: AP
"(Two weeks) does not allow enough time to adequately consult with experts, deliberate, discuss and... come up with a sustainable strategy to preserve Hagia Sophia for future generations," Tugba Tanyeri Erdemir, of the University of Pittsburgh, told AFP.
The Byzantine mosaics, plastered over for centuries when the building served as a mosque, will be hidden with curtains during prayer times since Islam bans figurative representations.