A least nine people have been killed in an attack on Somalia’s interior ministry before security forces killed all three attackers during a two-hour gun battle inside, police said

A number of people, mostly government workers, had been trapped in the ministry on what had been a normal business day.

Witnesses said some employees died or were injured while leaping from windows or walls in an effort to escape the attack, which was claimed by the al-Shabab extremist group.

More than 10 people were wounded and the death toll could rise, Colonel Ahmed Mohamed said.

The attack began in the morning when a suicide car bomber detonated at the gates of the interior ministry compound, which is close to the presidential palace and parliament headquarters and also holds the security ministry, police Captain Mohamed Hussein said.

Dozens of people were eventually rescued in the operation, Capt Hussein said, as ambulance sirens echoed and soldiers opened fire to disperse bystanders and motorists.

Somalia-based al-Shabab, an arm of al Qaida, often targets high-profile areas of the capital. It was blamed for the October truck bombing that killed more than 500 people in the deadliest attack in the country’s history.

The threat from what has become the deadliest Islamic extremist group in sub-Saharan Africa has hurt efforts to strengthen Somalia’s fragile government and stabilise the long-chaotic Horn of Africa nation.

The US under the Trump administration has stepped up military efforts in Somalia, including dozens of drone strikes, against al-Shabab and a small presence of fighters linked to the Islamic State group. At least two US military personnel have been killed.

The US military and others in the international community have expressed concern about the plan for Somalia’s security forces to take over the country’s security from a multinational African Union force over the next few years, saying the local troops are not ready.