Somalia's al Qaeda-allied group al Shabaab claimed responsibility for the bombing.

The suicide bomber had disguised himself as a regular soldier and joined others as they filed into a military base early Sunday before he detonated the explosive, Captain Aden Omar, a soldier at the military base told Reuters.

"We lost one soldier and several others were injured. The bomber blew up himself at a check point," he said.

A nurse at Madina Hospital in Mogadishu told Reuters they had received one dead soldier and six others who were wounded.

Al Shabaab claimed it had killed 32 soldiers.

"A Mujahid suicide bomber killed 32 apostate soldiers and injured over 40 others inside a base in Mogadishu today," Al Andalus radio station which is affiliated with the group said, quoting Abdiasis Abu Musab, al Shabaab's military operations spokesperson.

Abu Musab said they had targeted the base because recruitment activity was being conducted there.

The Islamist group frequently carries out bombings and gun attacks in Somalia and elsewhere.

Al Shabaab wants to topple Somalia's central government and establish its own rule based on its own strict interpretation of Islamic sharia law.

(Reporting by Abdi Sheikh and Feisal omar; Writing by Elias Biryabarema; editing by David Evans and Susan Fenton)