Abdulkadir Adan of the Amin ambulance service confirmed the five deaths to The Associated Press, and the service said at least 15 wounded people have been rushed to a hospital.
The blast occurred close to a school.
Al-Shabab in a statement carried by its Andalus radio said it targeted Western officials being escorted by the African Union peacekeeping convoy. But a witness, Hassan Ali, told the AP that a private security company was escorting the officials and said he saw four of the security personnel wounded.
The al-Qaida-linked group frequently targets the capital with attacks.