* Security gains fragile after two decades of war
* Somali government wants more support, training for police
* Diplomats say rebel attacks rarer, but more sophisticated
By Drazen Jorgic
MOGADISHU, June 27 (Reuters) - Somali Prime Minister Abdi Farah Shirdon has said last week's deadly assault on a U.N. compound in Mogadishu should not obscure the fact that many other attacks are now being foiled in a nation slowly recovering from war.
The attack by the al Qaeda-linked al Shabaab exposed the fragility of the security gains made since the Islamist militants were driven from Mogadishu by African Union and Somali government forces about two years ago. But Shirdon said it was not the whole story.
"Our efforts have reduced their attacks. For every one they plan, (which includes) two or three attacks each month, all of these are failing," he told Reuters on Wednesday inside Mogadishu's heavily guarded international airport. "Though we made a lot of efforts, this one did not happen to fail."
Diplomats also say attacks by the Islamist rebel group are becoming rarer, but warn of growing sophistication, an unnerving development for the diplomatic missions and aid organisations that have begun reopening offices in Mogadishu.
Gunmen blew a hole in the U.N. compound's wall with a car bomb on June 19 and shot their way in. After a fire-fight that lasted more than an hour, 22 people were dead, including the attackers.
Shirdon said security forces were becoming better at thwarting al Shabaab attacks, but needed more support. The government has long pleaded for more training, money and arms.
"For security, we are giving the highest priority to training our forces," Shirdon said. A new aid agreement called the New Deal will see the Somali government select the areas of priority that donor countries will focus on.
Somalis often note that their police receive only about $100 a month, while the African troops on whom the government still depends for security earn more than $1,000.
The U.N. compound attack was almost identical to an assault on Mogadishu courts in April, when more than 50 people were killed. It also showed al Shabaab is changing strategy.
The loss of urban territory and revenue streams in the last two years has weakened it as a conventional fighting force, pushing it towards a guerrilla-style insurgency.
"The attacks may be getting rarer and rarer but they are becoming bigger and more sophisticated," said one Western security adviser. "The U.N. attack also showed al Shabaab can conduct reconnaissance in Mogadishu pretty much at will."
One U.N. official said a "few dozen" U.N. staff temporarily left Mogadishu after the attack, and remaining workers were pulled back from scattered bases in the capital to the heavily fortified airport, where Britain has reopened its embassy.
But U.N. officials said they were not pulling out. U.N. Under Secretary General Jeffrey Feltman said in Mogadishu on Thursday that the attack would "strengthen our resolve" to stay.
The top U.N. diplomat in Somalia, Nicholas Kay, said the United Nations would continue building up its presence, but that no decision had been made about when various U.N. agencies would be able to leave the airport area.
"Fundamentally it doesn't change intent," Kay said. "The intent is that the U.N. should be here, present, and working alongside the Somalis in a way that we haven't over the last 22 years." (Editing by Edmund Blair and Kevin Liffey)