At least 15 people have been killed, including a controversial religious scholar, and 10 others wounded after a car bomb exploded followed by heavy gunfire in central Somalia, police and officials said.
Attackers of the armed group al-Shabab stormed into the religious centre of Sheikh Abdiweli Ali Elmi Yare in the north-central city of Galkayo in Mudug region, attacking the Sufi leader and his followers.
"The attackers used a vehicle loaded with explosives to make their way into the compound before shooting indiscriminately at people inside," Abdirahman Mohamed, a security officer, told AFP news agency.
"The targeted cleric was killed in the attack together with some of his followers," Mohamed said.
Captain Nur Mohamed, a police officer, told Reuters news agency that the security operation is now over.
"Three militants who stormed the centre were also shot dead," he said.
Al-Shabab, an al-Qaeda linked armed group based in Somalia, 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.
"We killed 26 people including the owner of the centre, his followers, his bodyguards and soldiers," Abdiasis Abu Musab, al-Shabab's military operation spokesperson, said.
"The owner of the centre was the man who abused the prophet," he added.
Residents of Galkayo, where the centre is located, and a regional official said Abdiweli may have been attacked because his centre hosts mostly youths who play music and dance.
Abdiweli had set up his own breakaway sect in Galkayo, attracting hundreds of followers who would play music and sing songs in praise of Prophet Muhammad, a form of worship abhorred by the armed group.
Al-Shabab said last year the scholar had referred to himself as the prophet, an accusation denied at the time by Abdiweli.
Abdirashid Hashi, the governor of Mudug region, told Reuters that the armed group had threatened Abdiweli on numerous occasions.
Al-Shabab, which has launched several attacks in Somalia and neighbouring countries, is fighting to topple the Somali government and wants to impose a strict version of Islamic law in the Horn of Africa country.
The group used to control most parts of the country, but since 2010, the fighters have been removed from most major towns and cities.
The group controls small sections of Mudug region, but it does not include Galkayo.
The United Nations has held an emergency session on what Ukraine has called "an act of aggression" off the coast of Crimea, following the seizure by Russia of three Ukrainian ships during a naval clash in the Black Sea.
The Security Council meeting on Monday came just a few hours before the Ukrainian parliament passed a proposal by the country's president to impose martial law for 30 days.
Addressing the council, Nikki Haley, US ambassador to the UN, warned Russia that the seizure of the ships on Sunday in the Sea of Azov was an "outrageous violation" of Ukraine's sovereign territory and urged the international community to condemn Russia's "arrogant" act.
Haley said such "outlaw actions" are preventing normal relations from developing between Washington and Moscow.
Russia has said the three ships - two small armoured artillery vessels and a tugboat - entered Russian territorial waters illegally.
Dmitry Polyansky, the Russian deputy representative to the UN, accused Ukraineof concocting a Russian threat in the Sea of Azov with Western support.
"Our country has never struck the first blow, but it can stand up for itself," he told the council, adding: "The population of the Crimea, as well as other regions of Russia, is under reliable protection."
Referring to Sunday's incident, Polyansky said Ukraine had planned the "provocation" in advance with the coordination of Western states, which he said had given the Ukrainian government "carte blanche".
Kiev has said its vessels did nothing wrong and has accused Russia of military aggression.
Volodymyr Yelchenko, Ukraine's ambassador to the UN, called Russia's claim that Ukrainian ships violated Russia's borders "an outright lie" and warning that rising tensions with Moscow "constitute a clear threat to international peace and security".
Also on Monday, NATO chief Jens Stoltenberg called on Russia to release the Ukrainian ships and sailors, saying there was no justification for Moscow's actions.
"What we saw yesterday was very serious," Stoltenberg told a news conference after an emergency meeting of the western military alliance held on Ukraine's request.
"There is no justification for the use of military force against Ukrainian ships and naval personnel, so we call on Russia to release immediately the Ukrainian sailors and ships it seized yesterday."
Earlier, Ukrainian President Petro Poroshenko signed a decree imposing martial law in response to the naval standoff with Russia. The move was approved by parliament on Monday night.
Poroshenko ordered an emergency session of Verkhovna Rada, Ukraine's lower house of parliament, to take place on Monday during which legislators voted on the decree.
The law will be imposed for 30 days from Wednesday onwards.
Al Jazeera's Andrew Simmons, reporting from Kiev, said there was a "palpable anger" throughout the country but Poroshenko's call for martial law had raised some eyebrows given the decision could affect upcoming elections.
"(Poroshenko) has to do something pretty special to regain popularity in these elections, the cynics and members of his own coalition are suspicious of his motivations in calling for martial law."
Addressing fears of heightened tensions between Kiev and Moscow, the 53-year-old also said on Monday that the step did not mean a declaration of war against Russia.
"Ukraine is not planning a war against anyone," he told the National Security and Defence Council.
Poroshenko also said Ukraine would stick to the Minsk Agreements, peace deals his government inked with Russia and pro-Russian separatists in southeastern Ukraine that were designed to stop a war that claimed more than 10,000 lives since 2014.
The conflict began after pro-West protesters overthrew pro-Russian President Viktor Yanukovych in February 2014, after months of violent protests in the capital, Kiev.
The separatists claimed the new, fiercely anti-Russian government planned a "genocide" of ethnic Russians in eastern regions, Ukraine's rust belt and Yanukovych's support base.