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 offencive 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 today 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".
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.
Also Read
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.
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.
While security forces have since improved, they are still struggling to make significant gains in offencive operations, and a major push to retake executed dictator Saddam Hussein's hometown Tikrit has made little progress in more than two weeks.