Colonel Mohamud Aden said that 20 other officers were wounded by the blast, some of them seriously.
The bomber, with explosives strapped around his waist and torso, infiltrated General Kahiye Police Academy and targeted officers gathering for special morning exercises, Captain Mohamed Hussein said.
The officers were rehearsing for Somalia's Police Day celebrations scheduled for December 20, Hussein said.
The bomber walked into the police academy undetected and joined a long line of officers in the rehearsal parade before he detonated the explosives under his sportswear, Hussein said.
Police officer Farah Omar who was at the scene at the time of the blast said the bomber targeted a spot where dozens of soldiers had gathered.
"He wanted to inflict a maximum damage," said Omar.
The Somalia-based al-Shabab extremist group quickly claimed responsibility for the attack. Al-Shabab, which is allied to al-Qaida, carries out frequent bombings and attacks against hotels, checkpoints and other high-profile areas of Mogadishu.
Al-Shabab has been blamed for the massive truck bombing in the capital in October that left 512 dead. Only a few attacks since 9/11 have killed more people.
The US has carried out at least 32 drone strikes this year against al-Shabab and a small but growing number of fighters linked to the Islamic State group, many of them defectors from al-Shabab.
A drone strike earlier this week against an al-Shabab vehicle carrying explosives prevented an "imminent threat to the people of Mogadishu," the US Africa Command said.
Disclaimer: No Business Standard Journalist was involved in creation of this content
