At least 21 people were killed in two separate suicide car attacks in Somalia on Saturday, one in Mogadishu and another at a military training base in the southern port city of Kismayo, police and military sources said.

Islamist militant group al-Shabab has lost control of most of their territories to African Union troops in recent years but they stepped up attacks in Mogadishu and elsewhere.

Sheikh Abdiasis Abu Musab, al-Shabab's spokesman for military operations, said his group was behind the car bomb in Kismayo.

The attack at Kismayo University, which is being used as a base for training government troops, was launched as soldiers were lining up for training, military officials said.

Colonel Ahmed Ato told Reuters at least 16 Somali soldiers were killed and 21 others were wounded in the blast.

The second car exploded in the capital Mogadishu at a busy junction in the evening. There was no immediate claim of responsibility for the Mogadishu attack.

"So far we know five civilians died in this evening's blast and seven others were injured," Mohamed Yusuf, the spokesman for the interior security ministry told reporters at the scene.

A Reuters reporter saw two burnt-out cars and a destroyed tea shop with blood stains nearby.

(Reporting by Feisal Omar and Abdi Sheikh; Writing by Duncan Miriri; Editing by Raissa Kasolowsky)