President Recep Tayyip Erdogan attended the prayers along with several hundred others after ordering the building to reopen for Muslim worship.
Crowds formed at checkpoints surrounding the building, where thousands of police forces were deployed to maintain security.
On entering the secured area, the worshipers — wearing face masks — sat spaced out on prayer mats in the city’s Sultanahmet Square.
“We are ending our 86 years of longing today,” said a worshiper, referring to the nearly nine decades since Hagia Sophia was declared a museum and ceased to be a place of worship.
“Thanks to our president and the court decision today we are going to have our Friday prayers in Hagia Sophia,” he added.
The 1500-year-old UNESCO World Heritage site was transformed from a museum into a mosque after Turkey’s top administrative court ruled to annul Hagia Sophia’s status as a museum earlier this month.
The court ruled that the building's use as anything other than a mosque was “not possible legally.”
Erdogan later announced that the mosque would be used for Friday prayers, with three imams appointed for congregational prayers.
He said that the mosque would remain open to people from around the world and that admission to the mosque would be free.
Erdogan visited the building along with a large entourage to inspect final preparations at the structure on Thursday.