MOGADISHU (Reuters) - When Islamist militants blasted their way to within 50 meters of the Somali president's residence, they forced a sharp rethink of security in the capital Mogadishu.
The deadly February 21 assault on the Villa Somalia compound was the closest al Qaeda-linked insurgents had got to President Hassan Sheikh Mohamud.
The assault by al Shabaab at the heart of government, and a bloody attack five months earlier on a Kenyan shopping mall, showcased the rebels' destructive reach at home and abroad and cast more doubt on Mohamud's pledge to improve security.
"The government's sugar-coated promises are the norm in Mogadishu. So too are bomb blasts," said 30-year-old Samira Farah, echoing widespread skepticism that Mohamud is capable of quashing the seven-year-old insurgency.
Since February, Somalia's Western-backed government and security services have taken new steps to improve security and regain the confidence of their potentially most effective ally - the public.
Spy chiefs, military bosses and commanders of peacekeeping forces from other African countries have been headquartered in one building.
Cabinet ministers have been asked to go out into Mogadishu's 16 districts to get closer to communities and rebuild trust in government in the hope the public will expose suspected rebels.
"Before the ministers were just in Villa Somalia wearing ties. Now they will be closer to people and reality," said former Somali cabinet minister Abdirashid Hashi, who heads the Mogadishu-based Heritage Institute for Policy Studies.
"The plan is one year late but it's never too late."
Mohamud has replaced the city's mayor, giving the new man the job of implementing a security plan that urges residents to shop neighbors believed to be collaborating with al Shabaab.
"The attack on Villa Somalia was a wake-up call," said one Western diplomat. "The president is now taking an active approach (to security), which I don't think was quite the case before."
The Horn of Africa nation's poorly paid and ill-disciplined army remains more a collection of rival militias than a cohesive fighting force.
Mohamud's government depends on the 22,000 or so African Union peacekeepers to survive, and the country's intelligence services are struggling to stay ahead of the insurgents.
"We can get more manpower but the problem is training, equipment, transport, communication," said Mohamed Ali Jama, director of the Ministry of National Security, who oversees Somalia's NISA spy agency and the national police.
There has been progress. In 2011, trenches running through Mogadishu marked the front line of al Shabaab's rebellion, while today Somalis returning home for the first time since civil war erupted in 1991 are financing something of an economic recovery.
The AMISOM peacekeeping force has scored successes driving al Shabaab out of bigger cities and towns. But the militants still control rural areas and smaller urban centers from where they launch al Qaeda-inspired suicide attacks.
Somali security officials say rebel fighters are once again infiltrating Mogadishu, a city of some 1.5 million, under pressure from a renewed military offensive by AU troops and Somali government forces across southern Somalia.
A new Mogadishu Security Strategy government paper says they are returning in search of hideouts and to "terrorize the civilians".
One intelligence agent said al Shabaab were able to assemble car bombs and suicide vests inside Mogadishu, and smuggled pre-made explosives into smaller cities controlled by government and African Union troops.
The security gains of the past three years are under threat.
"I've not seen Mogadishu (security) this bad for some time," said one Western security adviser who knows Mogadishu well.
Academic Ken Menkhaus said al Shabaab was "both weaker and more dangerous" than before. Its overall fighting force has shrunk while its expertise in guerrilla-style warfare had grown, he wrote in a U.S. military magazine.
SPY ON YOUR NEIGHBOUR
The new security strategy for Mogadishu, drawn up just days after the Villa Somalia raid, hinges on obtaining more ground-level intelligence from Mogadishu's rubble-strewn streets.
Somali officials are confronted by a challenge they are reluctant to acknowledge: the infiltration of militants into government agencies.
Witnesses said the gunmen who raided the heavily guarded presidential complex in February, breaching checkpoints, wore military fatigues - a tactic used before by al Shabaab.
It prompted Somalia's prime minister to seek help from Western states.
"He asked if Somalia could be helped with a high-level criminal investigation, which needed to look at whether al Shabaab received 'inside' support," U.N. special representative for Somalia Nicholas Kay wrote to six Western envoys in a February 22 e-mail.
Britain and the United States sent investigators to assist.
Kay told Reuters the U.N. had temporarily reduced the number of its staff in Mogadishu because of the deteriorating security. In another February attack in the capital, al Shabaab targeted a U.N. convoy with a car bomb outside the main airport.
Somali security chief Jama told Reuters the local population was the most effective weapon to dismantle militants' networks.
"They can spot new neighbors, the people who come into the city and the activities of those neighbors," Jama said.
Locals are, however, wary about informing on insurgents to security forces, who have a reputation for taking bribes from detained Islamist fighters.
"We used to give the police information about where the fighters hid themselves. The police arrested the fighters but would release them hours later," said local elder Bile Osman.
"I know many people who fled or were killed after fighters they identified were released," he said.