People had travelled thousands of miles and slept on the cobbled streets to get a spot inside.
In Istanbul, a city famed for its towering minarets and echoing calls to prayer, Friday Islamic prayers on Friday returned to the Hagia Sophia for the first time in almost 90 years.
Wearing a white skull cap, Turkey's President Recep Tayyip Erdogan led the pre-prayer recital, and for many in the crowd, he was the personal righter of an historic wrong.
"It should never have been turned into a museum," said Ufuk Tavusbay, 26, who had travelled from Belgium with his younger brother for the opportunity to pray at the mosque. "If you knew what it felt to Muslims, then you'd understand".
Originally built as a Byzantine cathedral in 537 AD, for centuries the Hagia Sophia was a Greek Orthodox church, though it had a spell as a Roman Catholic cathedral in the 1400s.
Following his conquest of Constantinople in 1453, Ottoman leader Sultan Mehmet the II turned the building into a mosque for the first time. It remained so until 1935.
Then, the Ottoman Empire fell, and in its wake rose Mustafa Kemal Attaturk, with his vision for a secular Turkey. Attaturk designated the building a museum, open to all faiths; an artefact of Turkey's religious and cultural diversity.