Botswana became the latest country to decriminalise homosexuality on Tuesday, celebrated by activists as a day of "pride, compassion and love."

In the landmark ruling, the southern African nation’s High Court rejected sections of the penal code that criminalise same-sex relations and impose up to seven years in prison.

High Court said in its ruling that penalising people for who they are is disrespectful, and the law should not deal with private acts between consenting adults. The right to privacy includes sexual orientation, which is innate and not a fashion statement, the judges said.

Prohibitive legal environments increase the vulnerability of gay men, transgender women and others to HIV, the statement said.

The ruling also cited the recent decriminalisation in India and elsewhere. It also pointed out that all three arms of Botswana’s government have expressed the need to protect the rights of the gay community.

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

Less than a month ago, Kenya’s High Court upheld similar sections of the penal code, dashing campaigners’ hopes the country’s colonial-era laws would be overturned.

More than two dozen countries in sub-Saharan Africa have laws criminalising gay sex.

“It is a day to celebrate pride, compassion and love,” UNAIDS executive director Gunilla Carlsson said in a statement after the ruling.

Earlier this year, the southern African nation of Angola also decriminalized same-sex activity and banned discrimination based on sexual orientation.

Those arguing against the laws criminalising gay sex say they leave people in the LGBT community vulnerable to discrimination and abuse while making it difficult to access basic health and other services.

Activists celebrate outside the High Court in Botswana (AP)

The Botswana-based non-governmental group LEGABIBO, which supported the anonymous petitioner in the case challenging the sections of the penal code, has said such laws “infringe on basic human dignity.”

Ahead of the ruling, LEGABIBO shared a comment attributed to president Mokgweetsi Masisi: “There are also many people of same-sex relationships in this country who have been violated and have also suffered in silence for fear of being discriminated.

“Just like other citizens, they deserve to have their rights protected.”

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

In recent years Botswana has taken other steps towards protecting LGBT rights.