Islamist militants attacked popular beachfront restaurants in the Somali capital Mogadishu, killing 20 people, the security ministry says.

The Beach View Cafe on Mogadishu's popular Lido beach was targeted by the al-Qaeda linked extremists who let off at least two car bombs at around 7.30pm local time (4.30pm GMT) on Thursday (21 January). A siege followed, lasting eight hours, but has now ended, the ministry said.

Early reports had said a suicide bomber had driven his car into the gates of the restaurant in Somalia's capital. Then at least five gunmen ran into the restaurant and took a number of hostages.

As police and government soldiers fought with the militants outside the restaurant a second huge blast, that took place about a half an hour later, shook the city centre. Eye witnesses said that the gunmen were shouting "Allahu akbar", Arabic for "God is great", as they fired high-powered assault rifles indiscriminately at civilians.

Al-Shabaab, which means "The Youth", is an off-shoot of the Islamic Courts Union – a rival administration to the Transitional Federal Government in Somalia. They aim to overthrow the Western-backed Somali government and impose its own version of Islam in the country.

Somalia has been devastated by civil war since 1991 and the extremists even controlled Mogadishu and the southern region of Somalia from 2006 until 2011, when it was defeated by African Union peacekeepers. The jihadists immediately claimed responsibility for the attack.

"We are inside and control the cafe," Sheikh Abdiasis Abu Musab, spokesman for al Shabaab's military operations announced, according to Reuters. "There are many casualties lying inside and outside the café."

The Somali Prime Minister, Omar Abdirashid Ali Sharmarke, took to Twitter to condemn the attack as "barbaric". The death toll is expected to rise after the brutal assault.

Major Farah Abdulle, a police officer at the scene of the incident said: "The second car bomb has just exploded and the fighters are still inside. We cannot know the number of casualties inside."

The beach lies to the north of Mogadishu and attracts thousands of mostly young Somalis. According to the BBC restaurants have begun to open up along the beach front in recent years and a wedding ceremony may have been taking place at the time of the attack.

In September last year the group stormed an African Union military base in Mogadishu, killing dozens of Kenyan troops. And only last week the Kenyan army were involved in a search and rescue operation in Somalia after Al-Shabaab militants killed more than 100 soldiers in an attack on a military base.