Botswana's High Court has rejected sections of the penal code that criminalize same-sex relations and impose up to seven years in prison.
Tuesday's unanimous ruling in the southern African nation calls the sections unconstitutional.
It comes less than a month after Kenya's High Court upheld similar sections of the penal code in another closely watched case.
More than two dozen countries in sub-Saharan Africa have laws criminalizing gay sex.
Those arguing against the laws say they leave people in the LGBT community vulnerable to discrimination and abuse while making it difficult to access basic health and other services.
The Botswana-based non-governmental group LEGABIBO says such laws "infringe on basic human dignity."
Early this year the southern African nation of Angola decriminalized same-sex activity and banned discrimination based on sexual orientation.