Hundreds of foreigners from Africa and outside the continent are battling Somalia's western-backed government in the worst clashes for months, the UN special envoy to the Horn of Africa nation said on Friday.
Intelligence agencies are worried that Somalia -- with its porous borders and coastline, al Qaeda-linked Islamist groups and weak government -- may become a beach-head for militants trying extend to their influence in the region and beyond.
Some observers play down that risk, saying most Somalis follow a moderate form of Islam and have a deep suspicion of foreigners and the strict interpretation of Islamic law espoused by groups such as al Shabaab.
"There is no doubt from many sources covert or overt that there is a significant number of foreign fighters in Somalia from within the continent and outside," UN envoy Ahmedou Ould-Abdallah told reporters in Kenya's capital.
"I have seen figures from UN Security Council documents, submitted by the US where they are estimated to be between 280 and 300," he said.
Fighting between al Shabaab militants -- who admit to having foreigners in their ranks -- and pro-government fighters has killed at least 139 people and sent some 27,000 fleeing the pock-marked, seaside capital since late last week.
"If (the rebels) take power by force, it will lead nowhere. There will be no recognition," Ould-Abdallah said.
World powers have condemned the violence in Mogadishu and called for calm in one of the world's most dangerous cities.
Analysts say foreigners have been training insurgents in explosives and tactics, while weapons such as landmines, grenade launchers and rockets have been flown and shipped into Somalia.
One security analyst said the roadside bombs being used to target African Union peacekeepers have become far more sophisticated in recent months.
Hardline opposition leader Sheikh Hassan Dahir Aweys told Reuters on Thursday there were some foreigners in Somalia, but that those numbers had been embellished.
Aweys -- who Washington says has links to al Qaeda -- also accused UN envoy Ould-Abdallah of "destroying" Somalia through his support of the transitional government.
Since early 2007, an insurgency against the government has killed 17,700 people and wounded almost 30,000 others, according to a local rights group.