Iraqi security forces have freed all the hostages taken by gunmen at a building in Baghdad next the ministry of human rights, officials say.
Three of the eight attackers were killed in the operation, an interior ministry spokesman told the BBC.
Security forces were quick to seal off the surrounding area, also home to the interior and transport ministries.
No group has claimed responsibility, though Sunni militants linked to al-Qaeda have mounted similar attacks.
Violence has surged across Iraq in the past year, reaching levels not seen since the height of the sectarian insurgency in 2007.
The United Nations says 7,818 civilians and 1,050 members of the security forces died in 2013. December alone saw at least 759 killed.