Gunmen attacked two restaurants in Somalia's capital of Mogadishu on Wednesday night, killing at least 18 people, a government spokesman said. Picture: Faisal Isse/Xinhua

Mogadishu - At least 20 people were killed and 35 wounded when fighters of Islamist terrorist group al-Shabaab attacked two popular restaurants in the Somali capital Mogadishu, police and witnesses said Thursday.

A suicide car bomber blew himself up at the entrance to the Posh Treats restaurant and hotel late on Wednesday.

At least five armed attackers then stormed the Posh Treats and the neighbouring Pizza House cafe, opening machine gun fire and causing panic and chaos, security officials and witnesses told dpa.

At least eight people, including six girls, were killed inside Pizza House, while at least three others were killed inside Posh Treats, police officer Ali Hassan told dpa.

The details about the others killed remained unclear early Thursday.

"Blood splattered across my clothes, and I had a piece of flesh on me, as people sitting around me were either dead or wounded," Said Yare, a customer of Pizza House restaurant, told dpa.

"There was blood everywhere, bodies everywhere in and outside of of the restaurant," Yare added.

A guest at Posh Treats, Olad Ahmed, told dpa: "I heard a large explosion and found myself lying under a table ... a girl next to me was dead."

The explosion site in Mogadishu, the capital of Somalia. Gunmen attacked two restaurants in Somalia's capital, killing at least 18 people, a government spokesman said. Picture: Faisal Isse/Xinhua

The siege, which started at about 1700 GMT on Wednesday, lasted ten hours, according to the police.

Somali Prime Minister Hassan Ali Khaire called the attack a "barbarous act of terrorism" on public radio.

Another senior member of the Somali security forces, Mohamed Hassan, said several people were rescued safe and sound by security forces.

Among them are foreigners from Kenya and Ethiopia who were employees at Posh Treats, according to Hassan.

Several guests, including Kenyan and Ethiopian nationals, could be rescued, he added.

Al-Shabaab claimed responsibility for the attack on pro-insurgent radio station Andalus shortly after the attack.

The group, which is seeking to establish an Islamist state in Somalia, is affiliated with the international al-Qaeda terrorist network.

Al-Shabaab regularly launches attacks on government buildings, hotels and restaurants in the volatile nation on the horn of Africa.