The dangers of turning Africa into a front in the "war on terror" – much as it was a front in two world wars and a cold war that were not of its making – have been starkly revealed in Uganda following the 11 July bombings that killed 76 people watching the World Cup final in popular nightspots. That atrocity was attributed to Somali al-Shabaab extremists seeking to carry out retribution for the presence in Somalia of Ugandan "peacekeeping" troops.

But there is no peace to keep in Somalia, where a transitional federal government (TFG), established under UN auspices in 2002, controls only a few blocks of the capital city and would have collapsed altogether but for a US-backed invasion by Ethiopia in 2006. Why did Uganda's veteran leader, Yoweri Museveni, rush in with military support for Somalia's decrepit regime where other African countries, barring Ethiopia and Burundi, had feared to tread?

One factor is that Museveni needs to project Uganda as a "responsible member of the international community" to deflect criticism of its own army's alleged pillaging in the neighbouring Democratic Republic of Congo. The Ugandan People's Defence Forces, built out of the guerrilla army that brought Museveni to power 24 years ago, are accused of human rights abuses while crushing rebellion in Uganda's northern region.

More generally, western aid still supplies around a third of Uganda's government budget, but donor countries were becoming uncomfortable with the corruption that has increasingly marred Museveni's long rule. Alignment with US-backed efforts to see Somalia pacified – so as to prevent the incubation and export of terror – serves both to smooth relations and to attract US logistical and training support for the Ugandan army.

Yet Ugandans, who have paid in blood for their country's part in the botched counter-insurgency efforts in Somalia, are now paying again in a clampdown on their civic freedoms. In a new round of security measures, the citizens of Kampala will need police clearance for all gatherings, including private parties and wedding receptions. "No gathering of more than five people, even if it is in your compound, should be held without clearance from the inspector general of police," the Kampala metropolitan police commander, Andrew Sorowen, told the press last week.

This measure comes as no less than 35 suspects await trial, which will be held behind the closed doors of the Luzira maximum security prison, charged with involvement in the 11 July attack. Sceptical Ugandans attribute the speed and number of arrests to a "beauty contest" between Uganda's various security forces – police, army and special operations units – vying for anti-terror funds.

A Kenyan lawyer who travelled to Kampala last week to represent one of the defendants was arrested and questioned by police before being put on a plane back to Nairobi. A Muslim human rights activist accompanying him remains in custody.

Curtailment of civil liberties is widely interpreted as a move to muzzle the opposition in the run-up to February 2011 general elections. Campaigning has already been marred by violence and fraud in the primaries to select candidates for the ruling party, headed by Museveni, who is seeking another 5-year term.

Thus, far from containing "Islamist" terror, efforts forcibly to pacify Somalia have created fertile ground – attractive to fanatics from outside that country – for it to develop and spread, while also risking fragile freedoms elsewhere

This fiasco has been led politically by Washington which, since the catastrophic American occupation of Somalia in 1993 (and given the sobering experiences of Iraq and Afghanistan), has preferred to see its security objectives advanced through African proxies and private security contractors.

Museveni, a lifelong warrior who does not know the meaning of the word "retreat", has proved a willing proxy. In a predictably bellicose response to the Kampala bombings, he increased Uganda's troop commitment to Somalia and led calls for other African Union states to send their own troops. The rules of engagement have been adjusted to allow peacekeepers to fire first if they feel threatened: a highly ambiguous directive that will leave nearly all actions in a grey zone.

Bolstering the Somali peacekeeping forces may be good news for US contractors such as DynCorp International, who equip and train the peacekeepers in Somalia with US state department funding. But it is hard to see how it is good for anyone else.