Some of Erdogan's supporters speak of the Hagia Sophia as the third holiest place in Islam, behind the Grand Mosque of Mecca and Al-Aqsa Mosque in Jerusalem.
In late May Erdogan participated remotely in a commemoration of the conquest of Constantinople held at the former basilica. An imam recited a verse called the Conquest surah, celebrating a treaty between the people of Mecca and Medina.
The ceremony drew protests from Greece's foreign ministry, saying it was an unacceptable breach of the world heritage site under UNESCO. For its part, the U.N. agency has said any changes to Hagia Sophia would require its approval.
U.S. leaders have also objected.
More in Middle East - Africa
"The Hagia Sophia holds enormous spiritual and cultural significance to billions of believers of different faiths around the world," U.S. Ambassador At Large for Religious Freedom Sam Brownback said on Twitter June 25. "We call on the government of Turkey to maintain it as a UNESCO World Heritage site and to maintain accessibility to all in its current status as a museum."
Before the July 2 court hearing, U.S. Secretary of State Mike Pompeo asked Turkey "to continue to maintain Hagia Sophia as a museum, as an exemplar of its commitment to respect the faith traditions and diverse history that contributed to the Republic of Turkey."
Numan Kurtulmus, deputy chairman of Erdogan's political party, responded that the decision is a matter of national sovereignty.
"The sole decision-making authority about the status of Hagia Sophia ... belongs to Turkey. We do not need anyone's advice or recommendation on our own affairs," he said, according to Reuters.
While the Eastern Orthodox Christian world is currently riled over disputes surrounding the Patriarch of Constantinople's recognition of the Ukrainian Orthodox Church as independent of Moscow, Russian Orthodox leaders have spoke out in favor of the status quo at Hagia Sophia.
"A threat against Hagia Sophia is a threat to all of Christian civilization, meaning our spirituality and history," Patriarch Kirill of Moscow said July 6. He said the former basilica of Constantinople is "one of the biggest monuments of Christian civilization"
"What could happen to Hagia Sophia will cause deep pain among the Russian people," said the Russian Orthodox patriarch.
(Story continues below)
Subscribe to our daily newsletter
Russian political leaders like Kremlin spokesman Dimitry Peskov have said Hagia Sophia is " a beloved world masterpiece for tourists from all countries who visit Turkey, including for tourists from Russia." In addition to its tourism value, it has "a very deep sacred spiritual value," he said.
Armenian Patriarch of Constantinople Sahak II Mashalian, an Oriental Orthodox leader, has suggested making Hagia Sophia a site of worship for both Christians and Muslims.
Turkey's population of 82 million is overwhelmingly Sunni Muslim. Non-Muslim minorities make up only 0.2%, and the Christian population is split among several Orthodox and Catholic Churches, as well as other groups.