Officials said the victims were collecting their pay at the army base in Dayniile, a suburb on the outskirts of the capital, the BBC reported.
An unknown number of people were injured and some were taken to hospitals, the BBC said.
The cause of the explosion wasn't immediately known. Also not known was who was behind the attack.
The militant Islamist group al-Shabaab was forced out of Mogadishu in 2011 but still stages sporadic attacks. The group, which has ties to al-Qaida, remains in control in many southern and central areas of the country.