Botswana has decriminalized homosexuality, a landmark decision in sub-Saharan Africa where more than two-dozen countries have laws criminalizing gay sex.
On Tuesday, Botswana's High Court ruled unconstitutional two sections of the country's penal code that made same-sex relations punishable by up to seven years in prison.
Judge Michael Elburu said the laws, many of which were holdovers from colonial times, oppressed a minority of the population, drawing cheers from activists who had packed the courtroom.
The court had been petitioned by a person who remained anonymous for security reasons.
Pro-gay activists were dealt a blow last month when Kenya's High Court upheld laws against same-sex relations. Before Tuesday's ruling, 28 out of 49 sub-Saharan countries had laws penalizing same-sex activity.
The Joint United Nations Programme on HIV and AIDS (UNAIDS) applauded Tuesday's ruling, saying criminalization of consensual same-sex relations is a violation of human rights. "It restores privacy, respect and dignity to the country's LGBT people, and it is a day to celebrate pride, compassion and love," said UNAIDS Executive Director Gunilla Carlsson.
Amnesty International urged other African countries to follow Botswana in ushering in "an exciting new era of acceptance."