Al Shabaab attackers detonated a bomb before entering a block that houses the office of Mogadishu's mayor around noon.

The ministry said security had killed six militants and cleared the area by 6pm.

Five civilians died, the ministry said. A police spokesperson put the death toll at six and the director of an ambulance service said they had transported eight civilian bodies.

Al Shabaab has stepped up attacks in a show of resilience after President Hassan Sheikh Mohamud's government launched a renewed offensive in August.

The group has been fighting the government since 2006 and seeks to impose its own interpretation of Islamic law.

It frequently carries out bombings and gun attacks across the country.

Sunday's attack was in a well-guarded area of the capital with concrete barriers and multiple road blocks.