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.
The Hagia Sophia was the Roman Empire’s first Christian cathedral and is among the best-known Byzantine structures in the world. It switched from a Greek Orthodox cathedral to a mosque in 1453, when the Ottomans conquered Constantinople and renamed the city Istanbul. The historic site then became a museum in 1935 as part of a decree by modern Turkey’s secularist founding father Mustafa Kemal Ataturk.
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.
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.”
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.