Turkey's top cleric has been attacked for comments deemed offensive to the modern republic's founder Mustafa Kemal Ataturk during a sermon at Istanbul's iconic Hagia Sophia which was reconverted to a mosque.
Ali Erbas, head of the top religious body known as Diyanet, presided over prayers at the monument on Friday at a ceremony attended by President Recep Tayyip Erdogan and thousands of others.
The prayers followed a court ruling to annul a 1934 decree making Hagia Sophia a museum under the new republic born from the ashes of the Ottoman Empire.
Hagia Sophia was built as a cathedral during the Christian Byzantine Empire in the sixth century. It was converted into a mosque after the Ottoman conquest of Constantinople in 1453.
But Erdogan signed a decree this month handing the building's control to Diyanet, so that it can operate as a mosque, a move which sparked criticism from the West.
In his Friday sermon, Erbas said: "Sultan Mehmet the Conqueror endowed and entrusted this outstanding place of worship as the apple of his eye to believers on condition that it should remain a mosque until the last day.
"Any property that is endowed is inviolable in our belief and burns whoever touches it; the charter of the endower is indispensable and whoever infringes upon it is cursed.
"Therefore, from that day to the present, Hagia Sophia has been the sanctuary of not only our country but also of Prophet Muhammad's ummah," Erbas added, referring to the Muslim community.
Opposition parties denounced Erbas, saying his comments clearly targeted Ataturk.
Ozgur Ozel of the main opposition Republican People's Party (CHP) said: "You cannot curse Ataturk while you sit at the chair of Diyanet founded by Ataturk.
"Ali Erbas, I swear that you will pay the price of damning Ataturk," Ozel said on Twitter.
The right-wing Iyi (Good) Party on Monday lodged a complaint against Erbas, accusing him of "violating the untouchable articles of the Turkish constitution".
On social media, the hashtag "Ali Erbas, know your place" was a trending topic.
One Twitter user, @yanikmehmetali, wrote: "When did you pray for Ataturk during your presidency? @DIBAliErbas, do not stay at Diyanet founded by Ataturk, quit."
The Turkish government has long been accused by its secular opponents of forcing Islamic values on the predominantly Muslim but strictly secular country.
Erbas however denied the claims, in an interview with Hurriyet daily.
"I referred to the future, not to the past," he said.
"Ataturk died 82 years ago. Prayers are said for anyone who dies, not curses."