Johannesburg: Botswana decriminalised homosexuality on Tuesday, with the High Court overturning a colonial-era law that punished gay sex by up to seven years in prison.
Same-sex relationships are illegal in more than 70 countries worldwide; almost half of them in Africa, where homosexuality is broadly taboo and persecution is rife.
"Discrimination has no place in this world. All human beings are born equal. Homosexuality is another form of sexuality that has been suppressed for years," Justice Michael Leburu said.
The case, which local media reported had been brought by a university student, argued the government should do away with the law in light of a changed society where homosexuality was more widely accepted.
Rights group Amnesty International welcomed the decision as "marking an exciting new era of acceptance, which should inspire other African countries to follow suit".
"With this ruling, Botswana has said ‘no’ to intolerance and hate and ‘yes’ to hope and equality for all people," Muleya Mwananyanda, Amnesty International’s deputy director for Southern Africa, said in a statement.
Botswana's ruling comes after Kenya's high court upheld its law banning gay sex, keeping same sex relations punishable by 14 years in jail, drawing strong criticism from the United Nations and rights activists.
Botswana's penal code, drawn up under British rule, had previously outlawed "carnal knowledge of any person against the order of nature", with those convicted facing up to seven years in prison, as well as "indecent practices between persons" in public or private, punishable with up to two years in prison.
Previous rulings have partially acknowledged the rights of lesbian, gay, bisexual and transgender people in the southern African country, including their right to equal protection before the law.
President Mokgweetsi Masisi also signalled his support for same-sex relations in a speech in December 2018, where he said LGBT citizens deserve to have their rights protected.
But when the case came to court in March, when the ruling was postponed until Tuesday, the lawyer for the state challenged those bringing the case to provide concrete evidence attitudes in conservative Botswana, where Christianity is the main religion, had changed.
"We still have a long away to go to engage all opposing factions, be it our religions community, our cultural community -- we need to engage them and educate them about the need to be tolerant," Cindy Kelemi, executive director of the Botswana Network on Ethics, Law and HIV/AIDS, told local newspaper MMEGI after the judgment.
Botswana is the latest country in Africa to decriminalise same sex relations, with Amnesty saying it follows Angola in January, Seychelles in June 2016, Mozambique in June 2015 and Sao Tome and Principe, and Lesotho in 2012.
South Africa is the only African nation to have legalised gay marriage.
This story has been published from a wire agency feed without modifications to the text. Only the headline has been changed.