Careful where you tread

Things do not seem to be going to plan for Kenya, which went to war for the first time in its history in mid-October. Within three weeks of invading neighbouring Somalia, the country's untested army had crashed a helicopter, torpedoed a fishing boat and bombed a refugee camp. The rainy season has turned tracks into quagmires, slowing the progress of 20,000 soldiers as they attempt to reach the port town of Kismayo, leaving them vulnerable to ambush.

The invasion followed a series of abductions of foreigners from Kenyan resorts and refugee camps which the government blamed on the militant Islamist al-Shabaab, the group that has been fighting a UN-backed administration in Somalia's capital, Mogadishu, since 2007. Kenya claimed that its troops were in "hot pursuit" of al-Shabaab kidnappers, but a plan to create a buffer zone against Somalia's chaos - a self-governing state called Jubaland - has been in the works since 2009.

Whatever the underlying motives, the war is proving hugely popular with the Kenyan media. Jingoistic headlines splashed across newspapers and television shows have drowned out dissenting voices. But, rather than make Kenyans and their guests safer, it has precipitated a series of grenade attacks on civilians in Kenya's capital, Nairobi, and elsewhere.

Al-Shabaab leaders in Somalia continue to exhort their followers to exact bloody revenge, and the kind of co-ordinated suicide bombing that killed 76 people in Uganda in July last year is now likely. "It is not a question of if, but when," warns Rashid Abdi at the International Crisis Group.

In Nairobi, people are fearful: shopping malls have cancelled events, bars and nightclubs are less busy than usual, and the streets are patrolled by soldiers. Yet there is also widespread support for the government's action: a sense that something had to be done about Somalia. "You cannot just let people hit you and hit you and never hit back," said Benedict Karanja, a taxi driver whose evening custom has dropped off in recent weeks.

Under pressure

Inside Somalia, the conflict risks strengthening al-Shabaab at a time when it is relatively weak. The persistent famine has diminished both its support and the number of potential recruits. Under pressure from government and African Union forces, it withdrew from Mogadishu in August, losing a valuable source of protection money and taxes.

Perhaps mindful of history - nothing unites Somalis like a foreign invader - Kenya has enlisted allies such as the Ras Kamboni militia, led by Ahmed Madobe. Shortly before the invasion, I visited Madobe's headquarters at Dhobley, a roughhouse border town in southern Somalia. Ras Kamboni looked much like any other Somali militia except for their box-fresh fatigues and new AK-47 rifles, which an intelligence officer, Abdikadir Bashir, said came from Kenya. "We were militias before; now we are a government," he said, rather hopefully.

The US denies supporting the invasion but in recent months its drone strikes have become more frequent and less deniable, handing al-Shabaab a potential rallying cry for Muslims to defend Somalia against Christian invaders. It was Ethiopia's US-backed invasion in 2006 that helped transform al-Shabaab into a powerful force. Another foreign invasion may be exactly what the group needs.