Illustration: Andrew Dyson
Among the raft of al-Qaeda groups that sprang up around the world after 9/11, the Somali branch of the franchise was not one of the more promising start-ups. A direct product of life in the most lawless corner of the planet, al-Shabab's followers were considered too violent and quarrelsome even to work with each other, never mind pose a threat to the rest of the world. For all their videos declaring themselves ''at Bin Laden's service'', the joke among Western intelligence agencies was that even al-Qaeda's high command would struggle to get anything organised in chaotic Somalia.
Two days ago, on what should have been a pleasant lunchtime in the affluent Nairobi suburb of Westlands, al-Shabab appeared to prove their doubters wrong. In a disciplined, highly co-ordinated attack, at least a dozen gunmen armed with assault rifles and grenades stormed a shopping mall popular with both locals and expatriates, embarking on an orgy of violence that was both savagely random and chillingly discriminate.
According to witnesses, Muslims - who make up about a third of Kenya's mainly Christian population - were ordered by the gunmen to leave the scene. Everyone else had to remain behind for the slaughter. Already the attack is the deadliest on Kenyan soil since al-Qaeda's 1998 bombing of Nairobi's US embassy, which killed more than 200.
High though the casualty figures were, the real shock was the way it was relayed in real time through digital media. Not only did fleeing shoppers take mobile phone footage of dead bodies and terrified mothers clutching their children, there was a gleeful running commentary from al-Shabab's Twitter feed, a 21st-century mouthpiece spitting 8th-century religious venom.
What the wider world witnessed, meanwhile, was the coming of age of a group that was all but unknown 10 years ago, but whose sympathisers in Somalia's vast diasporas now pose as much of a threat to Western interests as any other al-Qaeda franchise.
So who exactly is Harakat al-Shabab al-Mujahideen, to give it its full title? The shortened version of the name translates as ''The Youth'' - the current generation of which in Somalia has grown up with some of the bleakest prospects on the planet. Most have known nothing but anarchy in their home country, which has been without a properly functioning government since 1991. It is perhaps no surprise that many have broken with Somalia's long-standing tradition of moderate Sufi Islam to embrace more militant strains exported from the Saudi peninsula, which has set up vast numbers of madrassas in Somalia in the past 20 years.
I first heard of al-Shabab on a trip to Mogadishu in 2006, when a coalition of Islamists - including moderates - had managed to impose peace after nearly a decade-and-a-half of warlord thuggery. As we saw during a visit to a barracks outside the capital, the Islamists' trick was partly to put warlords' ex-foot soldiers through religious ''bootcamp'', converting yesterday's murderers, robbers and rapists into tomorrow's holy warriors.
But alongside the fragile peace came Taliban-style strictures banning music, dancing and most other kinds of fun. Fearing that Somalia's new Islamist overlords would also turn it into a haven for al-Qaeda, in early 2007 Washington authorised an invasion by neighbouring Ethiopia. Islamist rule was replaced with a transitional government propped up by United Nations mandate, Western cash and African Union troops from Somalia's mainly Christian neighbours.
The invasion also had the effect, though, of turning al-Shabab into an all-out guerrilla movement, divorced from its more moderate allies. It began a vicious insurgency against the transitional government, and also seized control of much of Mogadishu and swaths of southern Somalia, dreaming up edicts as ludicrous as anything imposed by the Taliban.
Teenage girls would be stoned to death for adultery, women were banned from wearing bras on the basis that they showcased the chest, and in 2010 men were even forbidden from watching the South Africa World Cup. For children, one of the few acceptable forms of entertainment was Koranic recital contests, for which prizes would include guns, grenades and land mines.
With the piety also came hypocrisy. While publicly condemning the piracy industry that boomed in Somalia from 2008, al-Shabab is also thought to have quietly taken fat slices of ransom payments in exchange for turning a blind eye to buccaneers on their turf.
In the last two years, the movement has been on the back foot, losing control of Mogadishu and alienating even its own followers through its refusal to let foreign aid agencies operate, a policy that caused a widespread famine.
But while its domestic fortunes have waned, its international agenda has grown. During the 2010 World Cup, al-Shabab bombers carried out their first major attack abroad, killing 74 people in an attack in Uganda, which contributed troops to Somalia's African Union force. One al-Shabab leader said: ''What happened in Kampala is just the beginning.''
Events over the weekend have now proved him right. The fear now, though, is how it might end.
Colin Freeman is the Chief Foreign Correspondent for the Sunday Telegraph.