In a momentous case that prompted celebration among gay people and civil rights activists around the continent of Africa, Botswana’s High Court overturned laws on Tuesday that criminalized homosexuality.

Yet the ruling was delivered only weeks after the High Court of Kenya upheld laws that criminalize gay sex, underscoring the wide differences in how L.B.G.T. people are treated across Africa, where views have been shaped by religion, diverse governments and colonial history.

What happened in Botswana?

An anonymous plaintiff, identified in court papers only as L.M., challenged the anti-sodomy laws last year. In a written statement read by the applicant’s lawyers in court, L.M. said, “We are not looking for people to agree with homosexuality but to be tolerant.”

When the case was brought before the court, a lawyer for the government argued that the law should not be overturned because it reflects the values of Botswana’s society, and pressed the challengers to provide evidence that those values had changed. But on Tuesday, three judges voted unanimously to revoke the laws.