A suicide car bomb was rammed into a military training base in the Somali port city of Kismayu on Saturday, killing "many soldiers", officials said.
Residents said they heard a loud blast followed by gunfire. Military officials said the attack was launched as soldiers were lining up for training.
"There are many deaths," Colonel Ahmed Ato told reporters at the scene. "We shall give details later."
Sheikh Abdiasis Abu Musab, the militant group al Shabaab's spokesman for military operations, said the rebels were behind the car bomb and there were several casualties.
Prime Minister Omar Abdirashid Ali Sharmarke confirmed the attack at Kismayu University, which is being used a base for training government troops.
"There was no aim achieved except the killing of brave Somali soldiers," he said in a statement, without giving a figure for the number of casualties.