analysisBy Ben Shepherd
Uganda's President Museveni approved a new law that imposes life sentences for homosexuality in defiance of opposition from international donors, with whom he has in any case not enjoyed warm relations for some time.
In the longer-term this may severely impact the president's popularity, but in the short term he will receive a much-needed domestic bounce.
President Museveni has signed into law draconian anti-homosexuality legislation, putting him on a collision course with donors, activists and NGOs, most prominently the US government. The part played by religious activists in pushing the new legislation has been widely discussed.
US-linked evangelical churches are hugely popular in Uganda, and have close links to prominent actors, including First Lady and Government Minister Jeanette Museveni and David Bahati, the MP responsible for drafting the legislation. This has undoubtedly been an enormously important factor in changing Uganda's traditional climate of relative tolerance.
However, there has been little analysis of the political calculus underpinning President Museveni's decision to sign the bill into law. The first half of the answer is found in Museveni's recent political weakness.
The National Resistance Movement (NRM), Museveni's political party, has fractured in recent years, losing support from longstanding allies and young turks alike.
Uganda's budget deficit and overwhelming infrastructural needs has left little in the pot to offer by way of sweeteners. A massive wave of young people is reaching voting age with no memory of Museveni the freedom fighter, just an out-of-touch and ageing autocrat.
With increasingly little room to manoeuvre, Museveni may be tempted by a turn to the well-worn tactic of anti-colonial populism. He has been trying to reinvigorate the NRM's founding mission as an agent of African liberation, stressing unity, nationalism and resistance of external influence.
In this context, harsh legislation on sexuality is a relatively easy win. Picking a fight with donors over LGBT rights both strengthens Museveni's claim to be bravely standing up to neo-imperial pressure, and appeals to a strong current of religious conservatism that can unite people across Uganda's heterogeneous regions, ethnicities and religions. Elections - due in 2016 - loom large.
The second part of the answer is perhaps a longer-term shift in the balance of power between African states and the donors that have dominated the conversation in the two decades since the end of the Cold War.
Museveni is at the forefront of a newly confident East Africa that seems to be coalescing around a core of Rwanda, Uganda and Kenya, which have struck recent deals on trade, freedom of movement and defence. Rwanda, famously, has had strained relations with donors in recent months, most importantly over allegations of involvement in the DRC.
Kenya has clashed with donors over the ICC cases against President Kenyatta and Deputy President Ruto. Any backlash against Museveni and Uganda as a result of this legislation would play out against a background of solidarity against perceived external meddling across the region, and could again work to Museveni's benefit.
And it may reflect a wider struggle across the continent to define a new 'African' politics. The era of the post-Cold War consensus - of progress measured in terms of technical governance-led development defined in Western capitals - may be waning. African economies, bolstered in many cases by natural resource revenues, are increasingly robust.
New investors - from China to Malaysia - bring support with few of the governance or human rights concerns of traditional donors. Young people, daily exposed to Western lifestyles through information technology, but largely excluded from participation by the iron hand of global socio-economic inequality, are likely to be fertile ground for new 'authentically' African identities.
That the worldview emerging from this process is, in many places, deeply hostile to LGBT rights is a tragedy, and a serious problem for donors - and not just because it is morally repugnant. It puts them in a no-win situation.
React too strongly and they risk strengthening the view that homosexuality is a decadent European imposition, playing into the hands of populists, risking long-term relationships and even making the situation on the ground worse. Stay quiet and they face serious criticism from activists, as well as losing a great deal of credibility as principled actors.
This is very likely to have been precisely the calculation made by Museveni - there is, unfortunately, very little downside to his signing the anti-homosexuality bill into law, at least in the short term.
He will face criticism from human rights groups, and even the loss of some donor funding, but he has not enjoyed warm relations with either for some time, and any loss would almost certainly be more than off-set by a much needed domestic bounce.
He is an extremely capable politician and would be quick to capitalize on any perception of coercion by donors. Given his prominence as an African statesman - after the death of Prime Minister Meles of Ethiopia he is East Africa's senior leader, and one of the longest serving on the continent - and it could also have serious long-term implications for shaping the terms of Africa's engagement with donors in years to come.
In the longer term, loss of donor support, income from tourism or external investment may lead to a cascade of increasing deficits, credit downgrades, more expensive borrowing and an erosion of government performance that could have serious implications - and severely impact Museveni's popularity.
But that is years in the future. For now, depressingly, the die seems to be cast.