The attack, on the building belonging to the Ministry of Transportation in north-east Baghdad, coincided with a month-long stand-off between the Iraqi army and anti-government fighters in the western province of Anbar.
A senior security source said the six militants took a number of hostages and killed nine of them inside the building, which was used to receive visiting delegations. It was not immediately known where the other victims died.
No group claimed responsibility for the attack but state buildings are a target for Sunni Islamist insurgents who have been regaining momentum in a campaign to destabilise the Shi'ite Muslim-led government.
More than 1000 people have been killed in Iraq since the start of the year, when militants seized control of two cities in Anbar.