Seven people were killed in an attack by Shabaab militants on a popular beachfront restaurant in the Somali capital Mogadishu, city authorities said on Friday.
"Nine people including two Shabaab gunmen were killed in the attack" on Thursday, Mogadishu city spokesman Abdifatah Halane told AFP.
Al-Qaeda linked Shabaab militants attacked the Banadir Beach Restaurant close to the city's Lido Beach, setting off a car bomb before exchanging fire with security forces.
The assailants also threw grenades at the security services who cordoned off the area. One man with a head wound was detained by the authorities which accused him of being the bomber.
The restaurant is popular with young people and government officials. Around 20 people managed to escape from the restaurant during the gunfight.
The Shabaab claimed responsibility for the attack in a statement distributed via the Telegram messaging service, claiming to have killed "scores" of people.
It said the restaurant was targeted because it was frequented by "apostates" indulging in "obscenity and vice".
The Shabaab is fighting to overthrow the internationally-backed government in Mogadishu, seeking to impose an austere Islamic rule on the country.
By Friday morning officials said the attackers had been killed.
All the "attackers have been gunned down and the restaurant is now under the full command of the Somali government soldiers," regional police commander Colonel Abshir Bishaar told the Somali National News Agency.
"The terrorist attack killed nine persons, five of them were civilians, two security forces and the other two were the militants who carried out the attack," Bishaar said, adding that two other civilians were injured.
It is the second time this year the group has attacked the Lido beach area and its many eateries, including upmarket establishments popular with business people and diaspora Somalis who have returned home to the city.
In late January, Shabaab gunmen detonated a bomb before bursting into the Lido Sea Food Restaurant and spraying gunfire at terrified customers, killing 20 people.
The group is expected to try to violently disrupt elections due to be held in September and October.
Despite abandoning the capital five years ago, Shabaab still launches regular attacks against government, military, civilian and foreign targets.
The militants have also staged repeated attacks in neighbouring Kenya and a recent security analysis warned that the group was expanding its horizons with cells active in Djibouti, Ethiopia, Kenya, Tanzania and Uganda as well as Somalia.