Botswana High Court has upturned a colonial-era law that criminalize consensual same-sex relations in a ruling that gives victory for Africa’s LGBTQ movements.

Under section 164 of Botswana’s Penal Code, “carnal knowledge of any person against the order of nature,” was an offense that carried a maximum sentence of seven years imprisonment.

Section 167 made “acts of gross indecency” — whether in public or private — a punishable offense, with up to two years in prison.

Letsweletse Motshidiemang, 21, brought the case to court in March arguing that society had changed and that homosexuality was more widely accepted now.

While homophobic attitudes continue to prevail in parts of the country, Botswana’s LGBTQ activists and supporters have marked some victories for the movement in recent years.

The 2010 Employment Act made it illegal for employers to terminate contracts on the basis of sexual orientation, and two landmark rulings in October and December 2017 laid the foundation for trans people to more easily change their official gender on identity documents.

Following a brutal attack on a transgender woman last November, Botswana’s President Mokgweetsi Masisi signaled his support for LGBTQ people, saying “there are many people in same sex relationships in this country who have been violated and have also suffered in silence for fear of being discriminated. […] Just like other citizens, they deserve to have their rights protected.”

Tuesdays’ historic ruling is win for LGBTQ activists and supporters in a country — and region — where homosexuality remains largely a taboo.

According to the International Lesbian, Gay, Bisexual, Trans and Intersex Association (ILGA), only 32 countries out of 54 African countries have enacted laws making it illegal to have gay sex.

Gay sex in parts of Nigeria, Somalia, and in Sudan, is punishable by death; in Mauritania the death penalty is a possible punishment. In Tanzania, being convicted of having same-sex relations can result in life sentences.

In January, Angola’s parliament adopted a new penal code, for the first time since it gained independence from Portugal in 1975, which paved the way for lawmakers to remove the provision characterizing same-sex relationships as “vices against nature.”

In 2015, Mozambique removed anti-gay laws, while São Tomé and Cape Verde have abolished laws criminalizing gay relationships.

Although Kenya struck down the change to the law that criminalizes homosexuality in May — and remains a deeply conservative and religious society — its courts has shown some independence in recent years regarding LGBTQ matters.

However, attempts to further criminalize homosexuality have been taken in countries including Uganda, South Sudan, Burundi, Liberia, and Nigeria over the last five years, according to an Amnesty International report.

In some African countries, conservative leaders continue to spread harmful and false rhetoric, in which they “openly and falsely accuse LGBTI individuals of spreading HIV/AIDS and of ‘converting’ children to homosexuality,” according to the report.