Kenyans, Americans, a Briton and Tanzanians were among 26 people killed when Islamist gunmen stormed a hotel in the Somali port city of Kismayo.
It was the deadliest attack in the city since insurgents were driven out in 2012.
A car bomb exploded at the hotel in the southern port city while local elders and lawmakers were meeting on Friday night, before three gunmen stormed in, police said.
Security forces took 11 hours to end the siege.
The dead included a presidential candidate for August's Jubbaland regional elections, Jubbaland state president Ahmed Mohamed Madobe said.
At least two journalists and a UN agency staff member were also reported to have been killed.
Al-Qaeda-linked Islamist group al-Shabaab, which is trying to topple Somalia's weak, UN-backed government, immediately claimed responsibility for the attack.
The group's military operations spokesman Abdiasis Abu Musab said militants killed 30 people and four al-Shabaab fighters also died.
The jihadist group tends to give different casualty figures than government officials.
Regional president Madobe said three Kenyans, one Briton, two Americans and three Tanzanians were among those killed.
"Four militants attacked the hotel. One of them was the suicide car bomber, two were shot dead and one was captured alive by Jubbaland security forces," he said.
Madobe said 56 people were wounded in the attack, including two Chinese citizens.
Police said all the attackers were killed.
Kismayo is the commercial capital of Jubbaland, a region still partly controlled by al-Shabaab.
The group's fighters frequently carry out bombings in Somalia and neighbouring Kenya, whose troops form part of an African Union peacekeeping force.
Two journalists were among the dead: Somali-Canadian Hodan Nalayeh, the founder of Integration TV, and Mohamed Sahal Omar, a reporter for SBC TV in Kismayo.
Nalayeh's husband Jama Fariid was also killed, the Jubbaland president said.
Canada's immigration minister Ahmed Hussen posted a tribute to Nalayeh on Twitter.
"Through her work as a journalist, Hodan highlighted the community's positive stories and contributions in Canada. She became a voice for many. We mourn her loss deeply, and all others killed in the #KismayoAttack," he wrote.