Police spokesman Maj. Mohamed Hussein said the attacker strapped explosives to his body and infiltrated the General Kahiye Police Training Academy during an early morning parade.
“Police were preparing for the 74th anniversary of police day. As they wanted to start exercise, a suicide bomber came in and blew up himself. We lost 18 police officers and 15 others were injured,” Muktar Hussein Afrah, Somalia’s deputy police commander, told reporters at the blast scene.
“Police will always continue their work despite death.”
Police earlier put the death toll at 15.
Reuters witnesses who attempted to visit the site of the blast said police had sealed it off. Hours later when they were allowed in, a witness saw body parts suspected to be from the bomber on the ground in the field where police officers had been training.
The witness said the ground nearby had also been washed to remove blood stains and people were burying bodies at the police academy.
The militant group Al-Shabab claimed responsibility for the attack and gave a higher death toll.
“We killed 27 police (officers) and injured more,” Abdiasis Abu Musab, the group’s military operations spokesman, told Reuters. Al-Shabab carries out frequent bombings in Mogadishu and other towns.
The group, which is allied to Al-Qaeda, is waging an insurgency against the UN-backed government and its African Union (AU) allies in a bid to topple the weak administration.
The militants were driven out of Mogadishu in 2011 and have since been steadily losing territory to the combined forces of AU peacekeepers and Somali security forces.
On Tuesday, the US Africom said the US military had conducted an air strike on a vehicle they said was strapped with explosives some 65km southwest of Mogadishu.
Thursday’s attack comes at a time when the AU is finalizing plans to trim its peacekeeping mission called AMISOM.
The 22,000-strong AU force is scheduled to leave by 2020 and some security experts say Al-Shabab could find it easier to stage attacks as the peacekeeping forces are reduced because government forces will find it hard to replicate their work.
At the same time, Somalia could become a safe haven for militants linked to Al-Qaeda currently in Yemen, the experts said.
The peacekeepers were deployed to help secure a government that has struggled to establish central control in a country that plunged into civil war in the early 1990s.