Being gay is effectively illegal in roughly 31 of Africa’s 54 countries, where consensual same-sex conduct is treated as a criminal offense carrying penalties that range from fines and short jail terms to life imprisonment and, in a handful of jurisdictions, death.1European Parliament. LGBTIQ+ in Africa Briefing The law varies sharply from one border to the next. South Africa has guaranteed marriage equality since 2006. Uganda introduced a death penalty provision for certain same-sex offenses in 2023. Most criminal statutes trace back to colonial-era penal codes imposed by Britain or France, though several governments have recently passed new, harsher laws framed as a defense of national values.
What the law says on paper and what police do with it are often two different things. In some countries authorities actively arrest, raid, and prosecute. In others the statute sits mostly dormant, functioning as a tool for social stigma, blackmail, and extortion. Both situations create real danger, and the practical risk in any given country depends as much on local enforcement patterns as on the sentence printed in the code.
Where It Is Illegal, Region by Region
Africa is not a single legal landscape. The region a country sits in, the colonial power that drew its borders, and the religious traditions in force all shape what the law looks like today.
Northern Africa
Legal systems across North Africa are heavily influenced by Sharia law and French civil law. Same-sex acts are generally criminalized under broad “public morality” provisions, and enforcement tends to be active, including against online activity. Mauritania sits at the extreme: its penal code prescribes death by stoning for Muslim men convicted of same-sex acts, though the country has maintained a moratorium on executions since 1987.2Human Dignity Trust. Mauritania Country Profile
Western Africa
West Africa contains some of the sharpest contrasts on the continent. Nigeria runs a dual system. The federal Same-Sex Marriage (Prohibition) Act of 2013 criminalizes same-sex relationships, gay organizations, and public displays of same-sex affection, with prison terms of 10 to 14 years.3Legal Information Institute. Same Sex Marriage (Prohibition) Act On top of that, 12 northern states apply Sharia law carrying a maximum of death by stoning for same-sex conduct.
Ghana’s parliament passed the Human Sexual Rights and Family Values Bill in February 2024, which would criminalize identifying as LGBTQ+ and penalize anyone perceived as supporting LGBTQ+ rights.4Office of the United Nations High Commissioner for Human Rights. Ghana – Turk Alarmed as Parliament Passes Deeply Harmful Anti-Gay Bill Mali, under a military junta since a 2021 coup, criminalized homosexuality and its “promotion” in October 2024.1European Parliament. LGBTIQ+ in Africa Briefing Cape Verde, by contrast, has no criminal prohibition on same-sex acts.
Central Africa
Cameroon enforces one of the continent’s most actively prosecuted anti-gay laws. Article 347-1 of its Penal Code punishes same-sex sexual activity with six months to five years in prison, plus a fine. Chad criminalized same-sex relations through a 2017 revision of its criminal code. The Democratic Republic of the Congo has no explicit prohibition but uses a general “public decency” statute to prosecute LGBTQ+ individuals in practice. Gabon and the Central African Republic have no laws criminalizing private, consensual same-sex acts between adults, though the Central African Republic does criminalize public same-sex displays of affection.
Eastern Africa
Eastern Africa has seen the most aggressive legislative activity in recent years. Uganda’s Anti-Homosexuality Act of 2023 introduced a death penalty for “aggravated homosexuality” and life imprisonment for other same-sex offenses.5Parliament of the Republic of Uganda. The Anti-Homosexuality Act, 2023 Kenya’s Penal Code continues to criminalize “carnal knowledge against the order of nature” with penalties of up to 14 years, and the High Court upheld the constitutionality of that provision in 2019. Tanzania and Sudan maintain severe penalties as well. Rwanda is the regional exception: it has never had a law criminalizing same-sex conduct, and a 2009 legislative attempt was shelved after the Justice Minister stated that sexual orientation is a private matter.
Southern Africa
Southern Africa is the most legally permissive region on the continent. South Africa legalized same-sex marriage in 2006 through the Civil Union Act. Botswana’s High Court struck down colonial-era criminalization statutes in 2019, and the Court of Appeal upheld that ruling in November 2021.6Human Dignity Trust. Attorney General of Botswana v Motshidiemang and Ors (2021) Mozambique removed references to “vices against nature” from its penal code in 2014. Angola followed in 2021, going further by adding anti-discrimination protections based on sexual orientation, including up to two years in prison for discriminatory conduct.
Namibia shows how quickly direction can reverse. Its Supreme Court ruled in May 2023 that foreign same-sex marriages must be recognized for immigration purposes, but the Marriage Act of December 2024 denies recognition of same-sex unions regardless of where they were performed.1European Parliament. LGBTIQ+ in Africa Briefing
What the Penalties Actually Look Like
Where same-sex conduct is criminalized, the sentence depends almost entirely on which country and which law applies.
- Fines and short jail terms, often in the range of six months to five years. Cameroon’s Article 347-1 is a representative example, with up to five years.
- Long prison terms of 7 to 14 years, common in former British colonies that inherited “carnal knowledge against the order of nature” provisions. Nigeria’s federal criminal code sets a 14-year maximum.
- Life imprisonment, which Uganda’s 2023 law imposes as the baseline sentence for a conviction of homosexuality.5Parliament of the Republic of Uganda. The Anti-Homosexuality Act, 2023
- Death. Uganda prescribes death for “aggravated homosexuality,” which covers repeated offenses or cases involving minors, people over 75, or people with disabilities. Mauritania’s penal code also prescribes death by stoning, though no execution for same-sex conduct has been carried out there since at least 1987. Twelve northern Nigerian states applying Sharia law maintain death as a sentencing option.5Parliament of the Republic of Uganda. The Anti-Homosexuality Act, 20232Human Dignity Trust. Mauritania Country Profile
Several recent laws reach well beyond the people directly involved in a relationship. Uganda’s act criminalizes “promoting” homosexuality with up to 20 years in prison and allows organizations convicted of advocacy to be shut down.5Parliament of the Republic of Uganda. The Anti-Homosexuality Act, 2023 Nigeria’s 2013 act penalizes gay organizations, public displays of same-sex affection, and anyone who witnesses or aids a same-sex union.3Legal Information Institute. Same Sex Marriage (Prohibition) Act Legal risk under those statutes extends to friends, landlords, and support networks.
Even where formal prosecution is rare, the presence of these penalties on the books gives police and private actors leverage for extortion and harassment. Someone who cannot report a crime without risking arrest under morality statutes is an easy target. Most of the day-to-day harm occurs in that gap between the written law and its street-level application.
Where It Is Legal
A growing number of African countries have removed criminal penalties for same-sex conduct, typically through court rulings that strike down colonial-era provisions as unconstitutional rather than through legislative repeal.
Botswana’s High Court struck down Sections 164 and 165 of the Penal Code in June 2019, and the Court of Appeal upheld that decision in November 2021, finding “no discernible public interest” in maintaining the prohibitions.6Human Dignity Trust. Attorney General of Botswana v Motshidiemang and Ors (2021) Mauritius followed in October 2023 when its Supreme Court declared Section 250 of the Criminal Code, which dated to 1838, unconstitutional. The court noted the law “was not introduced into Mauritius to reflect any Mauritian values but was inherited as part of our colonial history from Britain.”7Human Dignity Trust. Abdool Hakime vs State of Mauritius
Angola took a legislative route, enacting a new penal code in February 2021 that removed “vices against nature” and added protections against discrimination based on sexual orientation. Mozambique made a similar move in 2014. Rwanda has never criminalized same-sex conduct, and a 2009 attempt to introduce such a law was blocked.
Decriminalization is not the same as equality. Most countries that have removed criminal penalties have not followed up with marriage rights, adoption rights, or comprehensive anti-discrimination statutes. South Africa remains the only African country with a comprehensive constitutional and statutory framework protecting LGBTQ+ individuals. Its 1996 Constitution was the first in the world to explicitly prohibit discrimination based on sexual orientation, and in May 2024 the country enacted the Prevention and Combating of Hate Crimes and Hate Speech Act, which criminalizes hate crimes targeting LGBTQ+ individuals.8South African Government. Constitution of the Republic of South Africa, 1996 – Chapter 2: Bill of Rights1European Parliament. LGBTIQ+ in Africa Briefing Botswana prohibits workplace dismissals based on sexual orientation under its Employment Act. Mauritius includes sexual orientation in its Equal Opportunities Act.9MauritiusLII. Equal Opportunities Act
Where the Law Is Moving Right Now
The direction of travel since 2023 has gone both ways, with more countries tightening than loosening.
Uganda’s Constitutional Court reviewed the Anti-Homosexuality Act in 2024 and struck down some provisions, including mandatory reporting requirements and penalties for landlords who rent to LGBTQ+ individuals. The core of the law, including the death penalty for aggravated homosexuality and the 20-year sentence for “promotion,” survived.1European Parliament. LGBTIQ+ in Africa Briefing The United States shifted funding away from Ugandan government-linked organizations and relocated military events out of the country in response to the original act.
Namibia’s High Court declared in June 2024 that criminalizing sodomy between men while not criminalizing it between a man and a woman amounted to gender-based discrimination. By December 2024, however, the legislature passed a new Marriage Act that explicitly denies recognition of same-sex unions “wherever concluded,” overriding the Supreme Court’s 2023 immigration ruling.1European Parliament. LGBTIQ+ in Africa Briefing
Ghana’s parliament passed its Human Sexual Rights and Family Values Bill in February 2024, criminalizing LGBTQ+ identity itself along with any perceived support for LGBTQ+ rights.4Office of the United Nations High Commissioner for Human Rights. Ghana – Turk Alarmed as Parliament Passes Deeply Harmful Anti-Gay Bill Mali’s military government criminalized homosexuality and its promotion in October 2024. Gabon’s new constitution, approved by referendum in November 2024, does not criminalize same-sex relations but explicitly excludes same-sex couples from marriage.1European Parliament. LGBTIQ+ in Africa Briefing
Practical Safety for Travelers and Residents
Anyone LGBTQ+ considering travel to or life in an African country where same-sex acts are criminalized should treat the legal risk seriously, regardless of how rarely a particular law is enforced. Research the specific statute and recent enforcement patterns in each country on your itinerary. Border crossings can represent an abrupt change in legal status.
Public displays of affection, even gestures that would seem minor elsewhere, can attract attention in countries with active enforcement. The Australian government’s travel advisory warns that reporting a crime committed against you could itself lead to your arrest in countries where your identity or conduct is criminalized.10Australian Government Smartraveller. Advice for LGBTQIA+ Travellers Your home country’s embassy can provide limited consular help if you are arrested, but it cannot override the local legal system.
Digital caution matters as much as physical. Documented tactics in several restrictive jurisdictions include police creating fake profiles on dating apps to lure individuals into meetings that end in arrest. Once a phone is seized, officers extract contact lists, screenshots of private conversations, and photos to build cases against the individual and against the people in their contacts. A single arrest can cascade into a network-wide crackdown through this kind of chain targeting. Victims have reported being forced to sign false confessions under duress, or having officers send messages from their devices to broaden an investigation.
Practical measures include using encrypted messaging apps, turning off location-sharing, being cautious with photos that reveal identity or location, and reviewing social media before travel. Authorities in some jurisdictions also monitor LGBTQ+-themed websites and forums. In countries where entrapment has been reported, treat new online contacts with particular care.