At least 15 people were killed and 10 injured on Monday in the central Somali town of Galkayo when al-Shabab militants attacked a Sufi religious centre, a police officer said.
The Islamist militant group had accused the cleric of insulting Prophet Mohamed, which he denied.
“The (security) operation is now over. Al Shabaab killed 15 people including the cleric, his wife, his followers and his guards,” Captain Nur Mohamed, a police officer, told Reuters from Galkayo by phone.
The group was forced from Mogadishu in 2011 from most towns and cities but it retains a strong presence outside the capital and launches frequent bombings and other attacks in a campaign to topple the federal government.
The group took responsibility for the attack and put the number of dead at 26. It said some soldiers who responded to the first attack also died as they tried to remove a second car bomb.
A Somali police official said they had killed at least four Al Shabaab fighters.
Al Shabaab is fighting to establish its own rule based on its harsh interpretation of Islamic law. The group controls small sections on Mudug region, but it does not include Galkayo.