Al Shabab gunmen and a suicide car bomber struck a religious centre in central Somalia on Monday, killing a cleric and at least 14 of his followers before the attackers were shot dead by security forces.
"The [security] operation is now over. Al Shabab killed 15 people including the cleric, his wife, his followers and his guards," said police officer Capt Nur Mohamed from Galkayo, the capital of the Mudug region where the attack took place.
"Three militants who stormed the centre were also shot dead."
Al Shabab had accused the cleric, who was known as Abdiweli, of insulting Prophet Mohammed. Residents of Galkayo and a regional official said he may have also been targeted because his centre hosted mostly youths who played music and danced.
An Al Shabab spokesman put the number of dead at 26, saying some soldiers who responded to the attack were killed as they tried to remove a second car bomb.
"We killed 26 people including the owner of the centre, his followers, his bodyguards and soldiers," said Abdiasis Abu Musab.
"The owner of the centre was the man who abused the Prophet. The soldiers that died tried to drive a second car bomb that was left by the armed mujahideen."
The Al Qaeda-linked group was forced from the capital Mogadishu in 2011 and most other Somali 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.
Abdirashid Hashi, the governor of Mudug region, said Al Shabab had threatened Abdiweli on numerous occasions.
An elder in Galkayo said Abdiweli had provided free boarding to former pirates, street boys and jobless men and they became his followers.
"He used to tell teenagers: 'If you were a pirate, or a bandit, stop it and come and dance, eat food and sleep here. God will forgive your sins.' Some other ignorant teenagers thought he was as saint ... and so joined him," said Ismail Abdirahman.
"We understood there was something wrong with him but we could not take him to court because the man was well armed."
Al Shabab is fighting to establish its own rule based on its harsh interpretation of Islamic law. The group controls small sections in Mudug region, but not Galkayo.
In a separate attack in Mogadishu on Monday, at least three people died when a car bomb exploded in front of shops in the Wadajir district of the capital, police and witnesses said.
"A parked car laden with explosives exploded in front of shops. So far we know three people died," said Maj Mohamed Hussein, a police officer. "Death toll may rise because there are many shops there."