The bomber, who was reportedly wearing a police uniform with explosives strapped around his waist, infiltrated Gen. Kahiye Police Academy and targeted officers gathering for special morning exercises, Capt. Mohamed Hussein said.
The officers were rehearsing for Somalia's Police Day celebrations scheduled for Dec. 20, Hussein said.
The Somalia-based al-Shabab terrorist 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.
Al-Shabab has become the deadliest terrorist group in Africa and is increasingly targeted by the U.S. military after the Trump administration early this year approved expanded airstrikes and other efforts against the fighters.
The U.S. has carried out at least 32 drone strikes this year against al-Shabab and a small but growing number of fighters linked to the Daesh 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 U.S. Africa Command said.