The attack underscored the transitional government's vulnerabilities as UN-sponsored peace talks stalled in neighbouring Djibouti.
Somalia has been without a functioning government since 1991, when regional commanders ousted Mohammed Siad Barre, the then president, from power and then turned on one another.
The transitional government has struggled to defeat remnant Islamic Courts' Union fighters after the Ethiopian army wrested control of Mogadishu from the group in December 2006.
Thousands of civilians have been killed and hundreds of thousands forced from their homes in the protracted conflict.
Peace talks
The UN Security Council on Thursday approved a resolution calling for a UN political presence  in the country - the first in years - and said it would consider deploying peacekeepers to replace a small African Union force, if security improves and political reconciliation is achieved.
But another round of peace talks ended in Djibouti on Friday with no more than an agreement to meet again on May 31.
The Alliance for the Re-Liberation of Somalia, the main opposition alliance, which includes the Islamic Courts' Union, said it would not be involved in direct talks until the government agrees to a timetable for Ethiopian troops to withdraw.