As police gathered for their morning parade at the academy in Somalia's capital, a man wearing an explosive vest entered the camp disguised as a policeman and blew himself up, killing at least 17 and injuring 20.

This October 28, 2017 file photo shows a Somali soldier walking near a destroyed building after a car bomb was detonated in Mogadishu, Somalia.
This October 28, 2017 file photo shows a Somali soldier walking near a destroyed building after a car bomb was detonated in Mogadishu, Somalia. (AP)

A suicide bomber disguised as a policeman blew himself up inside a police training camp in Somalia's capital Mogadishu on Thursday and killed at least 17 officers, officials said.

Police spokesman Major Mohamed Hussein said the attacker had explosives strapped to his body and infiltrated the General Kahiye Police Training Academy during an early morning parade.

Earlier, officials said they had moved the bodies of 15 victims as well as 17 injured people.

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, said.

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 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.

Al Shabab's attacks come at a time when the AU is finalising plans to trim its Somalia peacekeeping mission called AMISOM.

The force of 22,000 deployed a decade ago but is set to lose 1,000 soldiers this month as part of a long-term plan to pull out of the country and hand security to the army.

The peacekeepers were deployed to help secure a government that has struggled to establish control in a country that plunged into civil war in the early 1990s.

Source: TRTWorld and agencies