The country's high court said in its ruling that penalising people for who they are is disrespectful, and that the law should not deal with private acts between consenting adults.
The judges said the right to privacy includes sexual orientation, which they said is innate and not a fashion statement.
The ruling also cited the recent decriminalisation in other countries such as India.
LGBT activists cheered in the courtroom after hearing the unanimous decision.
It comes less than a month after Kenya's high court upheld its ban on gay sex.
Gay sex is a crime in more than two dozen African countries.
Activists say such laws 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 has said such laws "infringe on basic human dignity".
Ahead of the ruling, LEGABIBO shared a comment attributed to President Mokgweetsi Masisi.
"There are also many people of same-sex relationships in this country who have been violated and have also suffered in silence for fear of being discriminated," he said.
"Just like other citizens, they deserve to have their rights protected."
Amnesty International told Sky News: "Technically, 'decriminalising' something is removing something from the criminal law and eliminating any sort of penalty or punishment for it.
"And technically 'legalising' is passing particular legislation to regulate something.
"So decriminalising gay sex would remove it from the criminal code, but it would not be legalised unless a specific law was passed to regulate it in some way."