Tunis (AFP) - Tunisia, where sodomy is punishable by jail, has committed itself to ban forced anal examinations to determine sexual orientation, the North African state's minister for human rights said on Friday.

The authorities carry out the tests on suspected homosexuals but "these exams can no longer be imposed by force, physical or moral, or without the consent of the person concerned", Mehdi Ben Gharbia told AFP, without giving a specific date for the change to be implemented.

Foreign and local rights groups have condemned the practice of forced anal exams as "cruel" and "inhuman".

Ben Gharbia said judges can still request that a suspect undergo the test "but that person has every right to refuse, without his refusal being held up as proof of homosexuality", under the change.

Tunisia is "committed to protecting the sexual minority from any form of stigmatisation, discrimination and violence", the minister insisted.

Tunisia's transition to democracy since a 2011 revolution against dictator Zine El Abidine Ben Ali has allowed for open debate on the situation of its gay and lesbian community.

But several youths were arrested on charges of homosexuality and convicted in 2016.

Homosexuality is still punishable by three years in jail under Article 230 of Tunisia's criminal code, which President Beji Caid Essebsi has said would not be repealed.

"Civil society must first be prepared" for such change in the conservative Muslim country, Ben Gharbia said.