At least 18 people have been killed and another 20 were hurt after twin explosions and gunfire rocked Somalia’s capital Mogadishu, ambulance officials said.

The first blast occurred near Somalia’s intelligence headquarters, according to security chiefs.

The second occurred near parliament, where security forces have engaged with gunmen thought to be trying to attack the presidential palace.

Extremist group al Shabab claimed responsibility for the blasts via its Andalus radio arm.

The explosions shattered months of relative calm in Somalia’s capital, which is often a target of al Shabab.

The Aamin Ambulance service ferried 18 bodies and another 20 injured people after the blasts, director Abdirahman Abdulqadir told the AP.

Mogadishu was the target of a truck bombing in October that killed 512 people in the deadliest attack in the Horn of Africa nation’s history.

Only a few attacks since September 11 have killed more people. Al Shabab was blamed.

Concerns have been high over plans to hand over the country’s security to Somalia’s own forces as a 21,000-strong African Union force begins a withdrawal that is expected to be complete in 2020.

On Thursday the head of the AU force, Francisco Madeira, said ending the pullout before 2021 “could bring about a serious risk of reversals that could derail the gains already made”.

Somali forces, he said, are not yet ready.