Mogadishu: A terrorist attack on a hotel in Mogadishu ended on Sunday after 29 people were killed during a siege lasting nearly 12 hours, police said.

The attack proved once again that insurgents can carry out deadly assaults in the heart of the Somali capital. Twin bombings in Mogadishu two weeks ago killed more than 350 people, the worst such attacks in the country's history.

The Islamist terrorists al Shabaab claimed responsibility for the attack on Saturday. The group wants to overthrow the weak, U.N.-backed government and impose a strict form of Islamic law.

"So far I am sure 29 people died - the death toll may rise," Abdullahi Nur, a police officer, told Reuters.

At least 12 of the dead were police officers, Nur said. And a woman, Madobe Nunow, was beheaded while her "three children were shot dead," he said.

A Reuters witness saw seven bodies lying inside the hotel.

Three militants were captured alive and two others blew themselves up after they were shot, police said. Some militants may have disguised themselves and escaped with the residents who were rescued from the hotel, one police officer said.

The attack began around at 5 p.m. on Saturday when a car bomb rammed the gates of Nasahablod Two hotel, which is close to the presidential palace, and destroyed the hotel's defences. Then gunmen stormed the building.

The explosion destroyed the front of the three-storey hotel and damaged the hotel next door. Many Somali officials live in fortified hotels for the security they offer.

Abdikadir Abdirahman, director of Amin ambulances, complained the emergency service had been denied access to the blast sight.

"After the hotel operation was over, we wanted to transport the casualties ... all entrances of the scene were blocked by security forces.

Al Shabaab said 40 people had been killed, including three of its fighters who stormed the hotel. The government and al Shabaab typically give different figures for victims in such attacks.

The twin bombings in Mogadishu on Oct. 14 killed at least 358 people, the worst such attacks in the country's history, igniting nationwide outrage. Al Shabaab has not claimed responsibility for that attack, but the method - a large truck bomb - is one it has often used.