A suicide bomber rammed a car into a Somali military base about 30 km (20 miles) northwest of the capital Mogadishu on Friday, killing one soldier, the military said.
The attack, claimed by the militant group al Shabaab, occurred when the base was almost empty shortly before Friday prayers, Major Abdullahi Ise told Reuters.
Three more soldiers were killed in a separate bombing targeting their truck as it headed into the capital with soldiers wounded in the first bombing, Ise said.
Al Qaeda-linked Al Shabaab carries out frequent bombings and other attacks in Mogadishu in a campaign to topple Somalia’s Western-backed federal government. A car bombing in Mogadishu last Friday claimed by the group killed 45 people.
The militants also want to drive out the African Union-backed peace-keeping force AMISOM which helps defend the government.
The 22,000-strong peacekeeping force began to withdraw troops in December and is scheduled to leave by 2020.
Somalia has been in a state of chaos and lawlessness since the early 1990s when dictator Mohammed Siad Barre was toppled by warlords.
President Mohamed Abdullahi has struggled to defeat the Islamist insurgency and restore security and stability despite support from the peace-keepers, Western aid and frequent airstrikes on Islamist targets by the United States.