At least 10 people were killed on Tuesday in a car bomb attack on a government building in the Somali capital of Mogadishu that was claimed by Islamist insurgents, a government official said.

Al Shabaab frequently launches attacks in Mogadishu and other areas controlled by Somalia's federal government. It wants to force out African Union peacekeepers, topple the Western-backed government and impose its strict version of Islam.

"More than 10 persons died, 20 others were wounded. The explosion destroyed the building of Wadajir District headquarters. More than 10 cars were destroyed in the explosion," said Abdifatah Omar Halane, a spokesman for the Mogadishu mayor.

Al Qaeda-linked al Shabaab said they were behind the attack, and its target was government officials.

"It's a suicide car bomb on Wadajir District building in which Somali officials and their staff stay. There are government and their staff who have died at the scene. We will tell you the number of dead later," said Abdiasis Abu Musab, al Shabaab's spokesman for military operations.

In an attack last week, al Shabaab fighters killed at least 19 people in a car bomb and gun attack on a hotel and nearby restaurant in Mogadishu.