At least 10 people have been killed after al-Shabab fighters attacked a beach restaurant in the capital Mogadishu with a car bomb before entering into a gunfight with security forces, according to police and the group.

"A car bomb exploded at Banadir beach restaurant at Lido beach and there is exchange of gunfire. We have no other details so far," Major Ahmed Ibrahim, a police officer, told Reuters news agency on Thursday.

The al-Qaeda-linked al-Shabab group claimed responsibility for the attack.

"We attacked the Banadir beach restaurant and now our fighters are fighting inside it," Abdiasis Abu Musab, its military operation spokesman, told Reuters.

The Associated Press news agency reported that a car bomber had prematurely detonated an explosives-laden vehicle near the new Turkish embassy compound in the capital, according to a Somali police officer.

Al-Shabab has carried out a series of deadly attacks in Somalia to try to topple the Western-backed government.

In January, its fighters stormed another restaurant on Lido beach, killing 17 people.

On Thursday, Reuters witnesses near the scene of the beach attack said the restaurant had been sealed off by security officers and that the attackers had lobbed grenades at the officers and fired at them.

They said they had also seen two bodies lying on the ground.

Internal Security Minister Abdirizak Omar Mohamed said on his Twitter account: "Warning: People near the blast scene should stay in the hotels and in their houses in which they are inside. Cars should not enter Lido beach area."

Al-Shabab was pushed out of Mogadishu by the African Union peacekeeping force AMISOM in 2011 but has remained a potent threat in Somalia, launching frequent attacks aimed at overthrowing the Western-backed government.

In a separate incident in southern Somalia, a roadside bomb believed to have been planted by al-Shabab fighters wounded at three people in Baardheere town in Gedo region, Colonel Hussein Nur, a police officer in the town, told Reuters by phone.

Al-Shabab was pushed out of Mogadishu by the African Union peacekeeping force AMISOM in 2011 but has remained a potent threat in Somalia, launching frequent attacks aimed at overthrowing the Western-backed government.

On Sunday, more than 20 people were killed when its suicide bombers detonated two car bombs at a local government headquarters in Somalia's semi-autonomous Puntland region.