Mohamed Abdi, a senior Somali police official, said the attack in the city of Beledweyne, about 339 kilometres north of Mogadishu, also wounded at least 10 others.
Many of those killed or wounded are civilians, he said, although it was possible some of the victims were government soldiers.
Beledweyne is under the control of the central government and African Union peacekeepers from Djibouti are stationed there.
No one immediately claimed responsibility for the attack, but the al-Qaeda-linked al-Shabab militants frequently stage such attacks on seats of power as well as restaurants and other public places that are popular with foreigners and government soldiers.
The al-Shabab militants claimed responsibility for a deadly attack last month on an upscale mall in Kenya's capital, Nairobi.
Al-Shabab said the September 21 attack, in which scores were killed in a four-day siege of the Westgate shopping mall, was in retaliation for Kenya sending troops into Somalia to go after the extremists.
