Melina Platas Izama is a PhD candidate in Political Science at Stanford University who writes about politics in sub-Saharan Africa.

Ugandan President Yoweri Museveni today signed into law his country’s Anti-Homosexuality Bill. The passage of this bill is part of an emerging trend of morality politics in Africa and beyond, including but not limited to the criminalization of homosexuality. Legislating morality, unlike improving social services like health and education, is nearly costless for politicians. It is also extremely popular. Legislators in Africa struggle to hold onto political power, and the majority of their constituents view them as corrupt, according to Afrobarometer surveys. Electoral pressures, combined with politicians’ poor record of service delivery, make legislating morality an increasingly attractive option. In addition to winning votes, however, laws such as the criminalization of homosexuality can also be used opportunistically against both the public and political opposition.

Uganda’s anti-homosexuality bill, which has been under discussion since 2009, criminalizes homosexuality and provides a punishment of life imprisonment for “aggravated homosexuality.” The law delineates particular same-sex acts as “aggravated homosexuality,” including sex with a minor or with a person with a disability, or if the offender is an HIV-positive person or a “serial offender,” defined as “a person who has previous convictions of the offence of homosexuality or related offences” (the Anti-Homosexuality Act, 2014: Sections 1 and 3). In the original bill proposed in 2009, “aggravated homosexuality” was punishable by death, and failure to disclose an offense committed by another person was punishable by imprisonment for up to three years. Both of these provisions were removed in the final version of the bill. However, in a news conference held immediately prior to signing the bill today, Museveni seemed unsure of the bill’s contents, asking his aides in the audience whether citizens were required to report on one another.

The anti-homosexuality bill reflects popular sentiment in Uganda, where 90 percent of respondents said that homosexuality was “never justified,” according to the World Values Survey, and 96 percent of respondents said that society should not be accepting of homosexuality, according to the Pew Global Attitudes Project. Uganda is no outlier on the continent. Kim Yi Dionne and Boniface Dulani, using all publicly available data on attitudes toward homosexuality in Africa, found that although higher levels of education, living in urban areas, and lower levels of religiosity were associated with greater support for same-sex rights, the vast majority of Africans oppose homosexuality. Dionne and Dulani point out, however, that the limited data collected on attitudes toward homosexuality in Africa fails to capture the salience of same-sex issues among ordinary Africans.

Uganda’s anti-homosexuality bill reflects trends across the continent in criminalizing (or re-criminalizing, since more than half of remaining “sodomy” laws worldwide are colonial relics) homosexuality. The reasons for the recent spike in anti-gay legislation (not limited to Africa, by the way) are still being debated. Guy Grossman suggests the rise in evangelical Christianity and heightened political competition explain the political saliency of LGBT-issues. These bills are undoubtedly politically popular, and thus useful tools for garnering electoral support.

David Bahati, sponsor of Uganda’s anti-homosexuality bill, was one of a handful of parliamentarians to run unopposed in Uganda’s most recent elections in 2011, in a country where competition over parliamentary seats is rising with every election. An average of more than five candidates contested for constituency parliamentary seats in the most recent election, up from less than four in 2006. Around half of the incumbents who ran for reelection were voted out of parliament in 2011. Bahati was subsequently elected vice chairman of the caucus of the ruling party, the National Resistance Movement (NRM).

At the presidential level, backlash and condemnation from Western countries, including the United States, where President Obama issued a statement warning Museveni that signing the bill would “complicate” the United States’ relationship with Uganda, have produced a rally-around-the-flag effect, where even Museveni’s most staunch opponents and a usually critical media have applauded his decision. Some have argued that he is calling Obama’s bluff, leveraging Uganda’s military role in the region. In any case, his signature, appended just weeks after members of his party passed a resolution in support of his bid for a fifth term in 2016, must be seen in the context of a presidential campaign season that has, for all intents and purposes, already begun.

Recent “moral” legislation extends beyond homosexuality, however, and focusing on the salience of LGBT issues may obscure other arenas in which moral dictates are being employed for political purposes. The signing of the anti-homosexuality bill in Uganda comes just weeks after the signing of the Anti-Pornography Bill, widely reported by local and international media as the “mini-skirt ban,” despite no mention of skirts in the bill itself. Legislating morality may seem odd in a country where more than three quarters of survey respondents believe “some of” or “most of” parliamentarians are corrupt, according to Afrobarometer data, but perhaps it is precisely because of their credibility deficit that politicians are employing moral dictates as a nearly costless alternative to delivering the goods and services that are so badly needed.

In addition to serving as quick and cheap political wins, these laws can also be easily converted into tools for political witch hunts. Ashley Currier demonstrates how leaders of the ruling party in post-colonial Namibia have used political homophobia to stifle dissent. Uganda’s political opposition seems all too quick to forget that opposition leader and former presidential candidate Kizza Besigye was jailed and taken to court on rape charges (in addition to treason and terrorism) in advance of the 2006 presidential election. The charges against Besigye were eventually dropped, but with Uganda’s new laws come a new arsenal of offenses; offenses that can mark if not jail a political candidate for life.

Apart from the intended consequences of these laws, unintended, if not unforeseeable, consequences are already becoming apparent. In countries where mob justice is a common replacement for weak or non-existent law enforcement, these laws give way to everyday opportunism. Immediately after the passing of the Anti-Pornography Bill, women wearing short skirts in Uganda’s capital city, Kampala, were reportedly attacked, disrobed and robbed. The Uganda Police Force had to issue an immediate warning against perpetrators of these attacks. Although it is too soon to tell whether citizens will also take the new anti-homosexuality law into their own hands, recent events in Nigeria suggest that mob justice against suspected or accused homosexuals may be swift, and potentially deadly.