Botswana's government on Monday lost a legal attempt to overturn a landmark ruling that decriminalised homosexuality.
The country's High Court in 2019 ruled in favour of campaigners seeking to strike down jail sentences for same-sex relationships, declaring the punishment to be unconstitutional.
But the government sought to revoke the ruling, arguing that the courts had no jurisdiction in this matter.
"Since the appellant's grounds of appeal have been unsuccessful... the appeal must fall," Botswana's Court of Appeal ruled on Monday.
It had started hearing the case in October.
Homosexuality had been banned since 1965 in conservative Botswana, where offenders could face up to seven years in prison.
The 2019 judgement was hailed internationally as a major victory for gay rights.
Judge Ian Kirby, who read out the ruling on Monday, said gay citizens had long lived in "constant fear of discovery or arrest" when expressing "love for their partners."
"This sometimes led to depression, suicidal behaviour, alcoholism or substance abuse," he said.
Botswana is one of only a handful of African countries to have decriminalised homosexuality.
Others are Lesotho, Mozambique, Angola and the Seychelles.
South Africa is the sole nation on the continent to allow same-sex marriage, which it legalised in 2006.