(CNN) -- Iraqi police have won back full control of a ministry building stormed by gunmen who took civil servants hostage, the Interior Ministry and security sources said Thursday.
Six gunmen were killed in the police operation to retake the Ministry of Transport in northeast Baghdad. Police killed four militants, while two of the militants detonated suicide vests, the sources said.
Two police officers were killed and seven injured in the attack. The hostages were freed unharmed.
Police earlier said that the militants had overrun the Ministry of Human Rights building, adjacent to the Ministry of Transport.
Roads were blocked around the Iraqi capital following the attack, and areas leading to Baghdad's fortified Green Zone were closed.
Separately, two car bombs exploded Thursday in different areas in the northeast part of the capital, killing four people and injuring 14 others. One hit a popular market area, a police source said.
The United Nations said 2013 was the deadliest year in Iraq since 2008, with almost 8,000 people killed in violence, most of them civilians.
Fears of all-out sectarian war have increased since fighting broke out at the end of last year to the west of Baghdad in Anbar province, where al Qaeda-backed militants and Iraqi security forces have been battling for control of Falluja and Ramadi.
More than 140,000 people have been made homeless since the new conflict erupted, according to Iraq's Ministry of Displacement and Migration.
The United Nations said last week it was scaling up its humanitarian response to help those displaced by the violence.
CNN's Mohammed Tawfeeq contributed to this report.