Turkish President Recep Tayyip Erdogan on Monday defended a top religious official who claimed homosexuality caused diseases, corrupted people and was condemned in Islamic teaching.

Ali Erbas, head of a state-funded agency called the Diyanet, which runs mosques and appoints imams, also claimed during his weekly sermon that homosexuality caused HIV.

The Ankara bar association of lawyers accused him of inciting hatred against gay people while ignoring child abuse and misogyny.

But Erdogan dismissed the criticism, saying "an attack against the Diyanet chief is an attack on the state" before adding: "What he said was totally right."

Erdogan's allies have attempted to shut down criticism of Erbas -- Ankara prosecutors have opened a probe into the bar association for "insulting the religious values adopted by a section of society" and Diyanet has made a criminal complaint against the lawyers.

"Ali Erbas, who voiced divine judgement, is not alone," said Erdogan's spokesman, Ibrahim Kalin, on Twitter -- echoing a popular hashtag.

Ali Erbas claimed during his weekly sermon that homosexuality caused HIV
Ali Erbas claimed during his weekly sermon that homosexuality caused HIV AFP / Adem ALTAN

The spokesman for Erdogan's ruling Islamic-rooted party, Omer Celik, insisted Erbas's comments were consistent with democratic values.

"Everyone has the fundamental right to speak in Turkey based on whatever value system they believe in," Celik said on Twitter.

On the other side, gay rights group Kaos GL said the religious chief had "spewed hatred" with "unscientific claims" and the Ankara-based Human Rights Association said it would file a legal complaint against him.

Diyanet was established in 1924 to oversee religion in secular Turkey after the abolition of the Islamic Caliphate in the wake of the Ottoman Empire's collapse.

Critics say the organisation has an outsized budget and is a symbol of creeping conservatism under Erdogan, despite Turkey being formally secular.

Although homosexuality has been legal throughout modern Turkey's history, gay people regularly face harassment and abuse.

In recent years, LGBT events have been blocked including Istanbul Pride, which has been banned five years in a row after taking place every year since 2003.