The al-Shabab extremist group claimed responsibility for the assault on the Banadir Regional Administration headquarters in Mogadishu.
A staff member at the headquarters said the attack began with a suicide bombing before gunmen entered and exchanged fire with security guards.
The staffer, Mustafa Abdulle, said most of the workers were rescued by security forces.
Al-Shabab often carries out attacks in Mogadishu.
The federal government last year declared “total war” on the extremist group and has retaken a number of communities the fighters had controlled in central and southern Somalia.
The founder of the Aamin ambulance service, Abdulkadir Adan,confirmed that his team collected 16 wounded people from the scene.