At least six people were killed when a suicide bomber blew himself up amongst a group of security officials outside the Somali prime minister's office on Tuesday, army officials said.
"I saw the dead bodies of six people and several others were injured," said Abdukadir Ali, a Somali military official who stayed near the scene of the attack in central Mogadishu.
It is believed that many of those killed or wounded were soldiers or police.
"The bomber was sitting near a perimeter wall and detonated himself in the midst of a group of security forces," Ali added. "There was chaos, smoke and pieces of human flesh."
Prime Minister Abdi Farah Shirdon Said was in his office at the time when the attacker struck, officials in his office said, but he was not harmed by the blast.
"The area was closed down by the security forces... I saw several dead soldiers and others injured being rushed to hospital," said Mohamed Hussein, a witness.
No group immediately claimed responsibility for the blast, but the Al-Qaeda linked Shebab insurgents have conducted a series of guerrilla style attacks in the capital.
The insurgents have vowed to topple newly elected President Hassan Sheikh Mohamud, who took office in September after being chosen by the country's new parliament, bringing an end to eight years of transitional rule.
Shebab fighters are on the back foot, having fled a string of key towns ahead of a 17,000-strong African Union force, which is fighting alongside Somali government troops to wrest territory off the Islamists.
Ethiopian troops are also battling the Shebab in the southwest of Somalia.
But the Shebab remain a potent threat, still controlling rural areas as well as carrying out guerrilla attacks -- including suicide bombings -- in areas apparently under government control.
War-ravaged Mogadishu was hit last year by a string of bloody bomb attacks, although it has been more calm in recent weeks.
A car bomb in December killed three people, while in November a suicide bomber attacked a restaurant.