Islamist militants said on Saturday their attack on the Somali president's compound, in which at least 11 people died, was an attempt to kill or abduct him.
Al Shabaab fighters blasted through a gate with a car bomb on Friday and fought a gunbattle with guards at the heavily-fortified compound known as Villa Somalia. President Hassan Sheikh Mohamud was unharmed in the assault.
"The main objective of attacking the palace on Friday was to assassinate the so-called Somali president or kidnap him," al Shabaab spokesman Sheikh Ali Mohamud Rage told Reuters on Saturday.
"We sent well-trained mujahideen from our special forces to bring us the president dead or alive."
In the past few weeks, the capital Mogadishu has been hit by a series of suicide bomb attacks claimed by al Shabaab, who were pushed out of the city in mid-2011 but have continued to wage a guerrilla campaign.
The strike was another reminder of the threat still posed by the rebels and how Somalia's fragile government is struggling to impose order more than two decades after the fall of dictator Mohamed Siad Barre tipped the country into chaos.
Police said the attackers wore uniforms similar to those of the presidential guards, and some wore suicide vests during the well-coordinated attack.
The chief of staff of the office of the prime minister and a former chief of intelligence were killed, along with all nine militants who staged the attack, the government said.
"In 2006, Ethiopian troops came but we chased them and by then we were weak," said Rage. "But now we are strong and determined to fight back and eliminate the Ethiopian troops."
President Mohamud said on Friday the attack would not stop his government's work to rebuild Somalia and called al Shabaab a "marginal group on the brink of extinction".
The president's spokesman said the rebels would be defeated.
"These are the death throes of a dying animal. Al Shabaab has been driven out of Mogadishu, Kismayo and many other areas. Our military campaign against them is going to remove them entirely," Abdirahman Yarisow told Reuters.
Somalia is preparing for a planned military offensive led by an expanded African Union peacekeeping force to drive the rebels - who want to impose a strict version of Islamic sharia law on the Horn of Africa country - out of their remaining strongholds by the end of 2014.
The offensive could push al Shabaab into the dense bush of the Lower Shabelle, a region that includes Barawe and lies between Mogadishu and the port of Kismayu to the south.
New joining the peace force from Ethiopia are expected to spearhead the offensive. Ethiopian troops have in the past been involved in similar drives against the rebels.