Nine al-Shabab militants wearing military fatigues and carrying guns and grenades died after attacking the presidential palace with two car bombs on Friday, in an assault the president called a "media spectacular" by a "dying animal."
President Hassan Sheikh Mohamud was unharmed, but two government officials were killed, the interior ministry said.
The attack underscores a worrying new trend in Mogadishu: That despite a period of relative calm following al-Shabab's ouster from Mogadishu in August 2011, militants have carried out a series of deadly assaults in recent weeks that have seen the city hit with mortar fire and pitched battles.
Weapons meant for the Somali army could have been used by the militants in Friday's attack. A confidential U.N. Monitoring Group on Somalia and Eritrea reported this month that the country's military is selling weaponry in markets where the al-Qaida-linked militants buy weapons.
In at least one case weapons were sold by a military commander directly to an al-Shabab commander, the confidential report said.
Friday's attack against the compound where the president and prime minister live began with a car bomb explosion, followed by an assault by gunmen on palace guards, said police Capt. Mohamed Hussein. Al-Shabab, an al-Qaida-linked group, claimed responsibility.
"President just called me to say he's unharmed. Attack on Villa #Somalia had failed. Sadly some lives lost. I condemn strongly this terrorism," the U.N. representative to Somalia, Nick Kay, said on Twitter. He added later: "The Somali people are tired of shootings, bombings and killings. It's time for a new chapter in Somalia's history.".