The al-Shabab extremist group claimed responsibility.
A police spokesman, Col. Abdiqani Mohamed Qalaf, said the suicide bomber tried to drive into the headquarters near the ex-control Afgoye road but was thwarted.
“He could have killed more people if not stopped,” Qalaf said. He said two soldiers and three passers-by were among the dead.
Dr. Hashim Suldan at Medina hospital told The Associated Press they had received 13 wounded people and two of them died on arrival. Others had serious wounds from shrapnel.
Al-Shabab often targets high-profile areas of Mogadishu, and observers had warned that the al-Qaida-linked group might take advantage of Somalia’s current political tensions to strike again.
The United Nations says tens of thousands of Mogadishu residents fled their homes this week after rival groups of soldiers clashed in the streets on Sunday amid a standoff over President Mohamed Abdullahi Mohamed’s extended stay in power.
The president in his address vowed that this week’s scenes of clashes between rival soldiers would not be repeated, while many Mogadishu residents who had feared a return to open warfare in Somalia sighed with relief.
Now the federal government and regional states are expected to return to talks soon on how to proceed with the election. Somalia has not held a direct one-person-one-vote election in decades as it rebuilds from some 30 years of conflict.