A suicide bombing Saturday at a military base housing African Union and Somali troops killed two Somali soldiers, a security official told AFP.
The target was the Afgoye military camp about 30 kilometres (20 miles) from the capital Mogadishu.
"The suicide bomber was trying to drive a minibus full of explosives past the guards but they ordered to stop before opening fire on him. He suddenly detonated and two soldiers were killed and three civilians injured," Mohamed Liban said.
"The attack was actually foiled as the bomber did not manage to enter the base," he said.
Muhidin Adan, an Afgoye resident, said: "It was a very strong explosion and smoke was rising up from the camp... The area was sealed off by the army."
The African Union peacekeeping force in Somalia is set to number about 15,000 with the integration of Kenyan troops sent by Nairobi separately to counter Shebab rebels linked to Al-Qaeda.
No AU soldier was wounded in the bombing, a source said, speaking on condition of anonymity.
Somalia's disparate leaders are struggling to form a government to replace the weak and corrupt Western-backed transitional body in Mogadishu, which is preparing to hand over power by an August 20 deadline.
Since the 1991 ouster of president Mohamed Siad Barre, Somalia has been variously governed by ruthless warlords and militia groups, each controlling their own limited fiefdoms.