Col Osman Dubbad, the commander of Djiboutian troops in the city of Beledweyne, near the border with Ethiopia, said pro-government forces killed 10 attackers, including two suicide bombers.
Col Ismael Ali, a police officer in Beledweyne, said five soldiers and four civilians were killed by a car bomb blast.
The officials said that gunmen forced their way inside the police station, where an hour-long gunbattle ensued.
According to a pro-militants website, the al-Qaeda-linked group al-Shabab claimed responsibility for the attack.