The blast hit a market in the Waberi area, while President Hassan Sheikh Mohamud was visiting a nearby university.
No group claimed responsibility, but suspicion fell on the Islamist militant group al-Shabab.
“There was chaos and severed dead bodies strewn around the street,” said Abdulahi Osman, a witness.
Ambulance workers says the death toll could rise substantially.
More than 22,000 peacekeepers are currently deployed in Somalia in the multi-national African Union force.
Al-Shabab, which wants Somalia to follow a strict version of Shariah law, opposes their presence.
Despite being ousted from most of its key strongholds in south and central Somalia, the Islamist group continues to launch deadly guerrilla attacks against the Somali government and foreign troops.