At least 20 Iraqi soldiers were killed on Saturday, most of them upon entering a house rigged with explosives northwest of the capital, security officials said.
Militants last week overran the house in the town of Garma, 30 km (20 miles) northwest of Baghdad, which had previously been used as an army post, officials said.
The army moved in on Saturday morning after militants retreated, but when they entered the house, a powerful blast tore through the building, two security officials said.
The identity of the attackers was not clear, but Sunni Islamist insurgents are regaining ground in Iraq and have taken over several towns and cities since the start of the year, including Falluja, around 70 km (44 miles) from Baghdad.
Ongoing violence has raised doubts parliamentary elections can be held nationwide later this month as intended.
Also in Garma, two government-backed Sunni militia fighters were killed when a mortar hit their post, security officials said.
Separately, three soldiers were killed and six wounded when a roadside bomb struck their patrol in Mishahda to the north of Baghdad, police and medical sources said.
An army colonel and three soldiers were also killed in an attack on their patrol in Mahmoudiya, south of Baghdad.
Of the 592 Iraqis killed in acts of violence in March, 108 were members of the security forces, according to figures published by the United Nations.