Kenya's High Court has blocked an attempt to overturn a law banning gay sex, in a significant set back for LGBT+ rights across Africa.

Judges claimed repealing British colonial-era laws would open the door to same sex marriage in a country and continent that continues to discriminate against LGBT+ citizens.

Many in Kenya's gay community had hoped the court would make history by scrapping the laws and inspiring other countries in Africa to do the same. Paul Muite, the main petitioner in the case, said he would appeal the decision.

Activists had argued the laws criminalising consensual same-sex relations between adults were in breach of the constitution because they deny basic rights. The state should not regulate intimacy between gay couples, they said.

One law punishes "carnal knowledge against the order of nature" and prescribes up to 14 years in prison for people convicted of homosexual acts. Another says "indecent practices between males" can bring up to five years in prison.

The worst destinations for LGBT+ holidaymakers Show all 10 1 /10 The worst destinations for LGBT+ holidaymakers The worst destinations for LGBT+ holidaymakers North Macedonia 16 per cent Getty Images The worst destinations for LGBT+ holidaymakers Moldova 14 per cent Getty Images/iStockphoto The worst destinations for LGBT+ holidaymakers Lichtenstein 14 per cent Getty Images/iStockphoto The worst destinations for LGBT+ holidaymakers Belarus 13 per cent Getty Images/iStockphoto The worst destinations for LGBT+ holidaymakers San Marino 13 per cent Getty Images/iStockphoto The worst destinations for LGBT+ holidaymakers Monaco 11 per cent Getty Images The worst destinations for LGBT+ holidaymakers Russia 10 per cent Getty Images The worst destinations for LGBT+ holidaymakers Armenia 6 per cent Getty Images/iStockphoto The worst destinations for LGBT+ holidaymakers Turkey 5 per cent Getty Images The worst destinations for LGBT+ holidaymakers Azerbaijan 3 per cent Getty Images/iStockphoto

The laws create an environment of fear and harassment even if they are not always enforced, activists said. "The issue is violence, discrimination and oppression," one activist, Tirop Salat, said.

But the judges, in a unanimous ruling, said those behind the appeal had failed to prove how the laws violated their right to health, dignity and privacy and said the laws do not single out gay people.

"Acknowledging cohabitation among people of the same sex, where they would ostensibly be able to have same-sex intercourse, would indirectly open the door for (marriage) of people of the same sex," said the judgment read in part by Justice Roselyn Aburili.

Activists were quick to condemn the ruling. "These old colonial laws lead to the LGBT community suffering violence, blackmail, harassment and torture. They devastate people's lives and have no place in a democratic Kenyan society," the Nairobi-based National Gay & Lesbian Human Rights Commission said after the decision was announced.

At least half of Kenya's LGBT+ persons have suffered physical and verbal assault, the commission said. Most assaults are not reported because people don't have confidence that police will protect them.

In a separate statement, the British LGBT+ organisation Stonewall called the decision "crushing news" and said some 70 countries around the world still criminalise same-sex relationships.

Thirty-three of those are in Africa, according to Human Rights Watch, which called Friday's ruling "a step backward in the progress Kenya has made toward equality in recent years".

Some in Kenya, however, praised the decision as a strike against what they called "sexual perversion." Gerald Walterfang with the Kenya Christian Professionals Forum said they were delighted with the ruling against what they termed a "destructive sexual lifestyle".

Five most anti-LGBT+ countries in Europe, according to ILGA-Europe

Kenyan Bishop Alfred Rotich added: "LGBT is an orientation. You cannot legalise something as an orientation. If somebody has an orientation to steal money, we cannot legalise it."

Kenya's courts had recently ruled in favour of LGBT+ rights.

Last year, an appeals court ruled unlawful the use of forced anal exams to test whether two men had gay sex. In 2015, High Court judges ordered a government agency to register a rights group representing gay people, saying Kenya's constitution recognises and protects the rights of minorities.

Resistance to gay rights exists at the top of Kenya's politics, however. President Uhuru Kenyatta said gay rights were "not of any major importance" and claimed the laws criminalising same-sex relations are supported by "99 per cent" of the Kenyan people.