analysisBy Charles Okwir
For the canny Museveni, the controversy over gay rights is not a moral issue but a political opportunity. And in this political chess game, he has so far outmanoeuvred everyone.
Earlier this month, just a couple of weeks after President Yoweri Museveni theatrically signed into law Uganda's controversial Anti-Homosexuality Bill, a group of individuals filed a petition challenging the new law in the Constitutional Courts.
One of the lead petitioners is Joe Oloka Onyango, a respected law professor, but perhaps more noteworthy is the involvement of Fox Odoi MP, Museveni's former legal advisor, and Andrew Mwenda, a journalist whose close association with the president is well-known and who was accused of being hired by the ruling party as recently as last December.
The question then is this: could Odoi and Mwenda have had the audacity to challenge Museveni so publicly without a wink and a nod from the president himself? Certainly, to some observers, that would be unthinkable. They argue that wily old Museveni, who has managed to stay in power for over 28 years, wasn't acting on moral conviction when he signed into law the Anti-Homosexuality Bill, and that for him, this whole affair is one of politics.
They suggest that Museveni's anti-gay act was partly a protest against the West and its African allies for forcing Uganda to withdraw troops from South Sudan, and partly a way for the president to endear himself to the Ugandan majority in the run up the 2016 elections.
If there is any truth in those theories, then it's not difficult to see why Museveni might find it useful to employ proxies such as Odoi and Mwenda to challenge his own law. If the court were to rule in favour of the anti-gay bill, Museveni's stance would seem to have been legally legitimised.
But even if the court were to find the law to be unconstitutional, Museveni could still claim to have taken a tough stand against homosexuality and say "I tried my best but the judiciary let me down." Meanwhile, the president would also get brownie points from Western donors for purportedly demonstrating that Uganda has an independent judiciary, an issue over which many Western observers have serious reservations.
Furthermore, it is highly possible that by the time the under-staffed Ugandan courts even consider the petition, Museveni will have already been re-elected, helped along by his populist anti-gay gimmick. Politically, the challenge may actually be of very little risk to the president.
Museveni, the chess master
Working out the possible outcomes of the legal challenge reveals two things. Firstly, that whatever the result, Museveni will be able to spin it for his own benefits, whether for domestic or international audiences. And secondly, that in the president's great chess game, Uganda's LGBT community features as little more than a pawn.
If certain analysts are to be believed, homosexuality is not a issue of morality for Museveni but one of pure politics. And while there are many reasons the president has been able to politicise gay rights so effectively for his own purposes, the West's inadvertent complicity in this should not be under-emphasised.
After Museveni signed the anti-gay bill into law in front of the world's media last month, a host of Western governments - arguably responding to outrage in their own countries more so than anything else - strongly condemned the new legislation.
They had little choice but to do so, and this outspokenness over the importance of upholding human rights cannot be criticised. However, their silence up until that point - over countless other human rights abuses in Uganda - and their warm friendship with Museveni for decades despite these violations can be criticised.
It would of course be unrealistic to expect the West to intervene whenever and wherever human rights are violated, but the huge inconsistencies in the West's foreign policy weakens its authority when it does speak out, and - given how predictable its contradictions are - can easily be manipulated by African leaders for political gain.
Before looking at Uganda itself, examining the West's relationship with some other East African nations clearly reveals its uneven regard for human rights.
In Rwanda, for example, President Paul Kagame has long been accused of orchestrating a systematic campaign to curtail fundamental rights and freedoms. Opposition leader Victoire Ingabire is currently in jail following a highly controversial trial at which she was convicted on charges of "terrorism" and "belittling" the 1994 genocide. Meanwhile various other politicians and journalists critical of Kagame have been found dead under suspicious circumstances. Under Kagame, Rwanda has also been accused of international-scale abuses including the looting resources in the Democratic of Congo and the funding of foreign rebel groups. Yet despite this highly questionable track record, the West has long treated Rwanda as an 'aid darling' and Kagame as a dear ally.
Similarly in Ethiopia, the late prime minister Meles Zenawi enjoyed a charmed position until his death from suspected liver cancer in August 2012. Whilst in power, Meles was accused, amongst other things, of rigging elections, murdering opponents, and clamping down on press freedoms.
Anyone critical of the government lived in constant fear and his regime repeatedly extinguished signs of dissent through violent means. Yet like Kagame, Meles was also one of the West's favourite African strongmen, and Ethiopia is one of the world's largest recipients of Western aid.
One can imagine that if either Rwanda or Ethiopia decided to pass new anti-gay legislation, the West's relative silence would finally break. If not by their own individual convictions, Western leaders would be forced by domestic constituencies to condemn the homophobic actions of their allies.
It is not this that is problematic - we should welcome tough talk in defence of human rights - but the years of relative silence that preceded the outspokenness means that sudden condemnation over gay rights would inevitably be interpreted by African citizens in a certain way. Would it be any surprise if Rwandans or Ethiopians came to think that the West cares more about gay rights than any of their other rights and freedoms?
This is what has happened in Uganda. In 2011, when the Museveni regime launched a crackdown on the opposition-led 'walk-to-work' protests, the West was muted. In May 2013, when the government shut down two leading independent newspapers, the international community largely looked on.
And later that year, when the Public Order Management Bill - which suffocates various fundamental civil liberties - was passed, the only noises Ugandans heard from the West were diplomatic statements about how they were "engaging" with the government and "urging it" to respect democratic freedoms.
By contrast, when the anti-gay bill was signed, countless Western leaders were unequivocal in their condemnation of the act, claiming they would have to re-consider their whole relationship with Uganda, and a number of Western donors went so far as to suspend aid.
Given that opponents of gay rights often claim homosexuality is an imperial imposition, and given that anti-gay legislation typically has popular support in conservative African societies, Western censure over the issue does little to damage the standing of African leaders in the eyes of their domestic audiences.
In fact, it can even play into their hands. Museveni, for example, could have signed the anti-gay bill into law quietly or taken measures to minimise international attention on the move, but instead he invited the world's media to the ceremony and provocatively announced: "It seems the topic of homosexuals was provoked by the arrogant and careless Western groups that are fond of coming into our schools and recruiting young children into homosexuality and lesbianism, just as they carelessly handle other issues concerning Africa."
In the eyes of his public, the ensuing storm of controversy only sought to validate Museveni's claims. The West's outrage and threats looked like the very interference Museveni had warned against, while its sudden concern for Ugandans' human rights seemed to confirm the president's suggestion that the West is only interested in gay rights.
If the West has learnt anything from this episode it is that it needs to adopt a new human rights strategy towards Africa. Western powers may think that they are having their cake and eating it by only denouncing human rights abuses when it suits them.
But as Museveni showed, it is often the case - particularly over gay rights - that the timing and nature of these occasional criticisms suit opportunistic African leaders even better. And ultimately in these situations, it is the LGBT communities that suffer.
Charles Okwir is a Ugandan journalist, writer and political analyst currently based in South Sudan, where he is working as a Communications & Reports Officer for the UN Development Programme. Follow him on twitter at @COkwir.