FIVE Islamic extremists have attacked a hotel at dawn in Somalia’s capital, Mogadishu, killing at least six people and injuring 10, before all the assailants were killed, a police official said.

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

“It’s over now, we have killed all the attackers,” said Ahmed. “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 men armed with AK-47 rifles, propelled grenades and suicide vests invaded the hotel.

Some of them went into rooms to kill residents while others went to the rooftop to fight government soldiers who came to fight the attackers, said Capt. Mohamed Hussein, a senior Somali police officer.

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

Among those killed was the hotel’s owner and a former military general, Hussein said by phone.

“Had it not been the courage of some of the hotel residents who fought back the terrorists, the death toll could have been a lot higher than its now,” Hussein said.

“They came in firing bullets randomly and chanting God is great — they shot anyone they could see,” said a surviving hotel resident, Ahmed Abdulle.

“The guards tried to fight them off but it was too late, they were already inside,” said Abdulle by phone from Mogadishu. “I hid myself under my bed until security forces broke into my room and got me out a back door. It was a terrible experience.”

Al-Shabab, the Islamic extremist rebels waging an insurgency against Somalia’s weak U.N.- backed government, claimed responsibility for the attack in a statement by Sheikh Abdiaziz Abu-Musab, the insurgents’ military spokesman, delivered on the group’s radio station, Andulus.

RELATED: al-Shabab are ‘bigger than IS’

Somali troops and African Union forces went to the scene and fought the attackers to take 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-Shabab’s insurgency.

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

“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.

Despite being forced out of Mogadishu and many other cities and towns across Somalia, al Shabab continues to launch lethal attacks in the capital and elsewhere. Al-Shabab is fighting to oust the Mogadishu government and install a strict version of Shariah law. Al-Shabab have 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.

The latest attack was condemned by Somali President Hassan Sheikh Mohamud.

“This is the action of an increasingly desperate, internally-divided group of extremists ... (who) seek to grab the headlines through killing innocent Muslims.”

Mohamud urged Somalians “to prevent extremists from distorting the faith of our fathers, and leading people astray in their quest for brutality and destruction. We must do this by confronting their warped ideology and liberating Somalia from them entirely.”