The country's High Court has overturned a colonial-era law with British roots that could punish people with up to seven years in prison. Botswana's president had also signaled his support for a change in a recent speech.
Botswana joined a number of other African countries in legalizing gay sex on Tuesday.
The ruling was met with approval by human rights group Amnesty International claiming it was "a victory in the battle for equality and freedom to love whoever you choose."
Muleya Mwananyanda, deputy director of the group for southern Africa, also hoped the judgement would have a continental knock on effect. "This court decision marks an exciting new era of acceptance, which should inspire other African countries to follow suit," she said.
The colonial law was overturned by Justice Michael Leburu as he said: "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."
The decision was well received in the courtroom as activists cheered in jubilation. Non-Governmental Organization LEGABIBO was represented by legal policy director Caine Youngman who said: "I'm a gay man. I've been out for many years. Now I can live with my partner without worry."
The news comes in the wake of Kenya's decision last month to maintain strict laws against same-sex relations.
(AP, dpa, Reuters)