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.
Last week, Erdogan ordered the conversion of the historic monument 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.
Erdogan has positioned himself as a friend of conservative Islamists in Turkey, moving the country further from those secularist roots.
UNESCO said earlier this month that it “deeply regrets” Turkey’s decision and that the choice was made without the organization receiving prior notification.
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.”
CNN’s Isil Sariyuce and Arwa Damon reported from Istanbul and Laura Smith-Spark wrote from London. Emma Reynolds contributed to this report.