BAGHDAD - Iraqi forces Saturday beat back an assault on Haditha in Anbar province, strategic for its large nearby dam, as the UN warned politicians must quickly form a new government or risk "chaos".
Fighting also erupted in the central province of Diyala as security forces battled militants who have seized swathes of territory and a string of towns and cities in an offensive launched on June 9.
The violence comes a day before Iraq's deeply-divided politicians are to hold a parliament session aimed at reviving flagging efforts to form a government in the face of the jihadist-led onslaught.
UN envoy Nickolay Mladenov on Saturday warned Iraqi politicians that "failure to move forward on electing a new speaker, a new president and a new government risks plunging the country into chaos".
"It will only serve the interests of those who seek to divide the people of Iraq and destroy their chances for peace and prosperity," he said.
The attack on Haditha, located northwest of Baghdad in Anbar province on the road linking militant-held western areas and the provincial capital Ramadi, began with mortar fire, police said.
Gunmen travelling in vehicles, including some captured from security forces, then attacked from two sides but were kept from entering the town in fighting that left 13 militants and four police dead, officers and a doctor said.
Previous attacks on Haditha were of a smaller scale and the capture of the dam by the militants would raise the prospect of it being used to cut water or flood areas downstream, as happened earlier this year elsewhere in Anbar.
In Diyala province, meanwhile, security forces and civilian volunteers Saturday launched a push to retake militant-held areas north of Muqdadiyah, a town on a main road to provincial capital Baquba, a police captain said.
But in a setback for government forces, militants overran the Shiite-majority towns of Al-Tawakul and Al-Zarkush in the province, displacing local residents, witnesses said.
In Jalawla, another Diyala town, Kurdish peshmerga fighters began a major operation to expel militants from areas they hold, a senior Kurdish officer said.
Major General Hussein Mansur said Kurdish forces were using tanks and artillery in the battle, and had succeeded in retaking territory from the militants.
Security forces folded during the initial offensive led by the Islamic State jihadist group, prompting the government to announce that it would arm civilian volunteers, thousands of whom have since signed up.
While security forces have since improved, they are still struggling to make significant gains in offensive operations, and a major push to retake executed dictator Saddam Hussein's hometown Tikrit has made little progress in more than two weeks.
As federal security forces quit their posts in northern areas during the initial fighting, Iraqi Kurds took control of a swathe of disputed territory that they have long wanted to incorporate into their autonomous region over Baghdad's strong objections.
They have kept areas from being overrun by militants, but the move has caused a major escalation in tensions between the Kurdish region and the federal government.
Kurdish authorities on Friday laid claim to disputed northern oilfields in a move slammed by Baghdad, further raising the stakes.
The Baghdad-Kurd row has dimmed the prospects of significant progress in forming a new government when parliament meets on Sunday.