Somalia's Islamic extremists attacked a hotel at dawn Sunday in the capital, Mogadishu, killing at least six people and injuring 10, a police official said.

Security forces ended the siege by five al-Shabaab attackers at the Sahafi Hotel by midday, said police commander Ali Ahmed.

"It's over now, we have killed all the attackers," Ahmed said. "They came under cover of darkness and attacked the hotel while some of the guards were sleeping."

The attack started at daybreak when a suicide bomber detonated a vehicle laden with explosives at the gate of the Sahafi Hotel and then gunmen ran into the hotel and shot at people, police Capt. Mohamed Hussein said.

"They have killed the owner of the hotel, a former military general, and other officials during the attack," Hussein said by phone.

A second explosion came from a car bomb outside the hotel, witnesses said.

Hotel targeted before

Al-Shabaab, the Islamic extremist rebels waging an insurgency against Somalia's weak UN-backed government, claimed responsibility for the attack in statements on the group's radio station, Andulus. The fighters infiltrated the hotel, Sheikh Abdiaziz Abu-Musab, al-Shabaab's military spokesman, told the radio station.

The militant group has struck hotels in Mogadishu before, including in March, when six of its fighters stormed a hotel and killed 18 people. It has even threatened targets in Canada.

Somali troops and African Union forces went to the scene on Sunday's attack and took control of the hotel, according to a Twitter post by the African Union Mission in Somalia, which has deployed troops to bolster Somalia's government against al-Shabaab's insurgency.

One photographer was among those killed and another was injured, according to witnesses.

Somalia attack on Sahafi Hotel

A Somali policeman surveys the destruction outside the Sahafi Hotel in Mogadishu following Sunday's attack. (Farah Abdi Warsameh/Associated Press)

"I was at the scene of the explosion busy taking photos when a vehicle full of explosives exploded beside me. I fell on the ground and saw part of my body bleeding, I was with another journalist who was killed in the attack," said Feisal Omar, who has since been discharged from the Mogadishu hospital.

The Sahafi Hotel is often frequented by Somali government officials and business executives and it has been targeted before. Two French security advisers were abducted from the hotel by militants in 2009.

Lethal cross-border attacks

Despite being forced out of Mogadishu and many other cities and towns across Somalia, al-Shabaab continues to launch lethal attacks in the capital and elsewhere. The group is fighting to oust the Mogadishu government and install a strict version of Shariah law.

Al-Shabaab has also attacked neighbouring countries that have sent troops to support the Mogadishu government. The extremist rebels killed 148 people in an attack on a college in Garissa, Kenya, in April.