Peering over the haphazardly developed and rolling Kampala hills, one would think German theologian Friedrich Martin Niemöller had Uganda in mind while authoring his indictment of the cowardice of German intellectuals during the Nazi massacre of Jews.

In the East African nation, Niemöller's words might be paraphrased as follows: "First they took revenge on supporters of the toppled government, and I did not speak out – because I was not a relative of any former president. Then they came for journalists, and I did not speak out – because I was not a media practitioner. Then they came for the skimpily dressed, and I did not speak out – because I wore long dresses. Then they came for political opponents, and I did not speak out – because I was apolitical. Then they came for the homosexuals – and the only people left to defend them were foreigners."

The state's intrusiveness into the private lives of its citizens has been overbearing in Uganda. Political activists cannot hold public rallies or meetings unless authorised by police. Those who defy the rule are fired with tear gas from trucks imported from South Africa, last used by the apartheid regime. Journalists are regularly locked up or prosecuted and two of the country's influential dailies were shut down for 11 days in May last year, for writing intensely on the locally touchy subject of President Yoweri Museveni's succession.

Early this month, Museveni signed the anti-pornography law that provides for sentences of up to 15 years in jail for merchants of pornographic material or those who wear clothes that expose body parts "likely to sexually arouse" others.

Homosexuality criminalised

The world heard little about these excesses, and the president continued to be fêted by the West – until this week, when he announced he would sign into law a Bill that prescribes a life sentence for gay men and lesbians convicted of "aggravated homosexuality".

In a scheme to buy time, Museveni on January 18 told Archbishop Emeritus Desmond Tutu and a visiting delegation from the Robert F Kennedy Centre for Justice and Human Rights that he would veto the "fascist" legislation.

The irony is that he not only promised to sign it after all, but also announced a day later that he was ready for a "fight" with pro-groups.

Why did Museveni, in power since 1986, shift the goalposts? The official version is that an ad hoc government-sanctioned team of Ugandan scientists convinced the president that there is no genetic predisposition to homosexual orientation.

Deputy presidential spokesperson Lindah Nabusayi said on February 18 that Museveni had yet to sign the anti-gay legislation passed last December, almost a week after promising to append his signature.

Relationship killer

United States President Barack Obama, who previously described the draft law as "odious", said its enactment would affect Uganda's "valued relationship" with Washington.

Critics say Americans have, over the years, strengthened Museveni's militant arm, enabling him to whittle down the space for free expression by harassing or buying opponents. For instance, Obama said nothing when demonstrators were shot dead in Kampala in 2009 and during the 2011 Walk-to-Work protests.

The US department of state only registered "deep concerns" over the blatant bloodshed in ways that analysts say appear to show the US has elevated the rights of gay people, the minority in Uganda, above other fundamental freedoms. Museveni's spokesperson Tamale Mirundi answered the US leader swiftly: "Uganda's relationship with the US was not built on homosexuality."

Ugandan President Yoweri Museveni. (Reuters)

The anti-gay law is popular with most Ugandans. By agreeing to assent to it after years of opposing it, Museveni will have charmed the largest political constituency ahead of the 2016 general elections.

It is worth noting that the president proclaimed his intention to sign the Bill at a retreat of the parliamentary caucus of the ruling National Resistance Movement party, where he secured an unprecedented – some say irregular – endorsement to be the party's sole presidential flag-bearer for the forthcoming ballot.

Majority vote

Almost all the ruling-party MPs, who number 270 out of the country's 375 law-makers, were happy when Museveni acquiesced to their demands for the anti-homesexuality law.

The president is almost certain of retaining power. He can take the risk of offending the West over homosexuals, secure in the knowledge that his new friends – Russia and China, both ambitiously scouting for opportunities in Uganda – would pad the financial gaps if Uganda's traditional donors cut aid.

Museveni may have snubbed the West because the US has unexpectedly ordered Uganda's military, the Uganda People's Defence Force (UPDF), out of South Sudan, where they have helped to salvage President Salva Kiir's government from collapse. Bureaucrats quietly speak of a betrayal by Washington at a time when the UPDF is doing its bidding by fighting the al-Shabab in Somalia, where better-equipped Americans soldiers failed in the early 1990s.

And because gay people in Uganda have scant support at home, now they are reaching overseas to make their case. Their campaign to have their rights protected in Uganda has gone viral on social media, where the majority of Ugandans are unfortunately not subscribers.

Social pressure

On Twitter and Facebook and other social networking sites, they have tagged top American officials such as Susan Rice, the US's national security adviser and its former UN ambassador, and human rights groups, to put pressure on Museveni.

"@AmbassadorRice your effort is appreciated. Sad indeed that he [Museveni] has chosen to do this to us. We shall soldier on," the Sexual Minorities Uganda (Smug) tweeted on their Twitter handle.

A Smug official tweeted: "Contrary to popular beliefs: No Ugandan can give a genuine reason why they're homophobic – simple ignorance."

For disagreeing with Americans, Museveni has adopted defiance – choosing to do what the US opposes, in defence of what he calls Uganda's sovereignty.

It's an argument that puts foreigners, not himself, to the test, and potentially on a collision course with the majority of Ugandans.

Tabu Butagira is a journalist with Uganda's Daily Monitor newspaper.