A suicide bomber blew himself up inside a Mogadishu army camp on Monday, killing at least three soldiers a day after the army chief escaped an attack on his convoy, military sources said.
"The suicide bomber was stopped at the main entrance and he blew himself up. Three soldiers died and several others were wounded," said soldier Abdukadir Farah, who was inside the camp at the time of the attack.
Farah said there had been a meeting of military officials underway at the camp.
But it was not clear if army chief Ahmed Mohamed Jimale was among them, he said.
Military official Lieutenant Colonel Mohamed Abdirahman told AFP the attacker had been "disguised as a member of the military" to gain access to the training camp.
The attack was claimed by the Al-Qaeda-linked Al-Shabaab extremist group, which said that "tens" of people had been killed.
The training camp in the south of the capital is one of the largest in the country.
On Sunday, a suicide bomber drove a car packed with explosives into a convoy carrying Jimale, who was named to the post last week by President Mohamed Abdullahi Mohamed, known as Farmajo.
The Shabaab claimed responsibility for the attack, saying the military chief had "narrowly escaped" the blast. A senior army official separately said the attack left at least 10 people dead.
Farmajo, who took office in February, also named new police and intelligence chiefs in a speech Thursday in which he declared a fresh war against Al-Shabaab militants.
"I am announcing a state of war in the country and call on the public to stand with the national army to help fight terrorists," he said.
"We are very sorry for those kids who have been misled, and we are offering the Shabaab fighters an ultimatum of 60 days to surrender otherwise they will face the consequences," he said.
While Shabaab have lost large swathes of territory and were forced out of Mogadishu by African Union troops in 2011, they continue to strike in the capital and countryside.
There has been an uptick in attacks over the past week, with a car bomb in Mogadishu that left seven people dead Wednesday, a landmine that killed 19 on Thursday and a mortar strike which left three dead on Friday.
Shortly after Farmajo's election, the Shabaab threatened to wage "vicious war" against his new administration.
Somalia's fragile central government is still propped up by the international community and a 22,000-strong African Union peacekeeping force after nearly three decades of civil war and anarchy.
During his inauguration, Farmajo warned there would be no quick fixes for the troubled country -- also on the brink of famine.
"Your problems were created during 20 years of conflict and droughts. A solution will need more than another 20 years," he said.