Picture: Supplied

Nairobi - A Kenyan court ruled Thursday that the forced anal examination of men suspected of being gay is unlawful, a verdict rights groups welcomed after arguing the tests constitute torture.

Homosexuality is illegal in Kenya, as in many other countries on the continent, and forced anal exams have been carried out against men arrested on suspicion of having homosexual relations.

"On Thursday... a three-judge bench handed down a ruling in a case appealing the state's cruel and degrading treatment of two Kenyan men while under arrest in 2015," a statement from Kenya's National Gay and Lesbian Human Rights Commission said.

"The humiliation and pain caused by these useless anal examinations will follow our clients for the rest of their lives," said the organization's head of legal affairs, Njeri Gateru.

Nearly 600 people in Kenya were prosecuted for homosexuality between 2010 and 2014, according to the latest government figures.

Another court case is underway to decriminalize gay sex, punishable by 14 years prison, with the next hearing expected in April.