The History and Ideology of a Militant Islamist Group, 2005-2012. By Stig Jarle Hansen. Oxford University Press; 208 pages; $37.50. Hurst; £25. Buy from Amazon.com, Amazon.co.uk

The World’s Most Dangerous Place: Inside the Outlaw State of Somalia. By James Fergusson. Da Capo Press; 432 pages; $27.50. Bantam; £20. Buy from Amazon.com, Amazon.co.ukIn this section

IN 2005 three dozen Somalis formed a club of Islamists, soon dubbing themselves the Shabab (Arabic for “youth”). Chaos had reigned over Somalia for a generation and there had been no real government since the military ruler, Siad Barre, fell in 1991. But within a year or so, the Shabab was the dominant force within a loose coalition of Islamic courts that had sought with some grim success to impose order.

By 2009 the Shabab, with a core of 5,000-odd fighters, had mastered a good half of the country and made most of the rest virtually ungovernable. Stig Jarle Hansen, the Norwegian author of one of two important new books explaining the rise of the Shabab, reckons it controlled an area “equal to the size of Denmark, with perhaps 5m inhabitants” (out of perhaps 10m in all). The Shabab, Mr Hansen believes, was then the world’s only self-proclaimed al-Qaeda ally controlling large territories. Because of a far-flung Somali diaspora of nearly 2m in America (especially Minnesota), Britain (London and Cardiff), Kenya (nervously adjacent to Somalia) and Scandinavia, the Shabab’s capacity for wreaking terror at home and abroad has frightened and flummoxed Western and African governments. These two books, “Al-Shabab in Somalia” and “The World’s Most Dangerous Place”, are essential reading for those who seek to counter the menace.

James Fergusson (who has contributed in the past to The Economist) has written the more readable work. With ingenuity and no little courage he has travelled far and wide, within Somalia and among the Somali diaspora in Britain and America, delving into the soul of a ravaged community. Few if any foreigners in the past half-decade have reached so deeply into the territorial nooks and crannies of Somalia’s myriad fiefs. Mr Hansen focuses on the complex ideological detours and military tactics of the Shabab from its inception. His is a succinct and definitive if somewhat dry history.

Both authors agree that although the bloody-minded Shabab is probably on the road to containment if not outright defeat, quite a lot of Somalis may still reluctantly accept it as the lesser of many evils. It certainly did better than its rivals at transcending the bitter divisions between the clans, sub-clans and sub-sub-clans (some 140 of them, according to Mr Fergusson) whose doggedly lethal loyalties were a main cause of the country’s fragmentation.

The Shabab is driven by local grievances yet has global aspirations, helping to stoke rebellion in such troubled places as northern Nigeria and Yemen. In the past two years the West has been trying to bolster a revamped government in Mogadishu, Somalia’s capital, while accommodating the semi-autonomous fiefs to build what might become a workable federation. Such efforts have been led by Britain’s prime minister, David Cameron, who happens to be a close friend of Mr Fergusson. But Somalia is still one of the most dangerous countries in the world, and its people still among the most tragically disturbed. The Shabab may be on the wane. But neither author predicts it will fade fast.