The car blew up in a car park near a local government compound, according to officials and witnesses.
The fatalities included a police officer and several civilians, police officer Ali Hassan Kulmiye said.
The civilians were having lunch in a nearby cafeteria, according to officials. Seven people were reported to have been injured.
The blast was believed to have targeted the administrative compound, which houses the mayor and other senior officials.
A spokesman for Mayor Yusuf Hussein Jimale said he had not been injured.
The attack was claimed by the Islamist group al-Shabaab, which said on pro-insurgent radio Andalus that it had killed 10 members of the security forces.
The blast damaged several commercial buildings, shattering their windows, witnesses said.