Militants from the Islamic State are battling ferociously to control one of Iraq's most vital resources: water.

Fighters with the group launched a three-pronged attack over the weekend in a drive to capture Haditha Dam, in western Iraq, a complex with six power generators located alongside Iraq's second-largest reservoir. At the same time, they are fighting to capture Iraq's largest dam, Mosul Dam, in the north of the country.

Seizing the dams and the large reservoirs they hold would give the militants control over water and electricity that they could use to help build support in the territory they now rule by providing the scarce resources to residents. Or they could sell the resources as a lucrative source of revenue.

They could also use the dams as a weapon of war by flooding terrain downstream to slow Iraq's military or disrupt life. They have done that with a smaller dam they hold closer to Baghdad. But with the larger dams, there are limits on this tactic since it would also flood areas that the insurgents hold.

On Friday, the fighters unleashed a powerful attack from three sides on the town of Haditha in western Anbar province. Suicide attackers tried but failed to detonate an oil tanker and several trucks packed with explosives. The aim was to obliterate the final line of defense between the militants and Haditha Dam on the Euphrates River, Lt. Gen. Rasheed Fleih, the commander of Anbar Operations Command, told The Associated Press.

For a brief moment, it seemed all was lost. The Sunni militants seized the army command headquarters in town, with very little stopping them from reaching the dam. But some local Sunni tribes who oppose the militants and feared for their livelihoods if the dam were captured sent fighters to reinforce the 2,000 soldiers guarding the town, allowing for a narrow victory. At least 35 militants and 10 soldiers were killed in clashes on Friday, Fleih said.

But the militants have been fighting every day since trying to take the town, according to four senior military sources in Anbar province. They spoke to the Associated Press on the condition of anonymity because they are not authorized to speak with the media.

Only 10 kilometers (6 miles) remain between the militants and the dam.

The jihadis are also closing in on the Mosul Dam — or Saddam Dam as it was once known — located north of Iraq's second-largest city Mosul, which fell to the militants on June 10. Fighting intensified in the region Sunday after the nearby towns of Zumar and Sinjar fell to the militants.

Kurdish forces, known as peshmerga, have managed to hold the fighters off for now, but the growing strength and savvy of these Islamic militants is raising grave concerns.

The peshmerga are "under a great deal of pressure now" as they defend a 150-kilometer (80-mile) frontline against the Islamic State group along the edges of the Kurdish autonomous zone in the north," Maj. Gen. Jabar Yawer, the official spokesman of the Kurdistan Region Guard Forces, told The Associated Press.

He said late Sunday there were fierce battles ongoing in towns and villages near the dam on the Tigris River. Fearing the worst, Prime Minister Nouri al-Maliki commanded his air force to reinforce the peshmerga Monday in a rare show of cooperation despite deep political divisions between al-Maliki and the Kurds.

"God forbid, if something happens that results in the destruction of the dam, it will be very, very dangerous," Yawer said.

Earlier this year, the group's fighters captured the smaller Fallujah Dam on the Euphrates when they seized the nearby city of Fallujah. Repeatedly, the militants have used it as a weapon, opening it to flood downriver when government forces move in on the city.

Worst hit has been the area of Abu Ghraib on the outskirts of Baghdad. In May, some 12,000 families lost crops and many fled their homes, worsening Iraq's growing crisis of internal displacement. The Special Representative for the U.N. Secretary General in Iraq called the incident a "water war," and called on Iraqi forces and local tribes to team up and take back Iraqi waterways.

Doing that with Hadith and Mosul Dams is more problematic, since militant-controlled lie downstream. But damage to either could be disastrous, particularly in the case of the Mosul Dam. It has millions of cubic meters of water pent up behind it on the Tigris River, which — some 370 kilometers (220 miles) downstream — runs through the heart of Baghdad.

"Everything under it will be under five to 10 meters (yards) of water... including Baghdad itself," said Ali Khedery, head of the Dubai-based consultancy Dragoman Partners and a longtime adviser to the U.S. military, government and companies in Iraq. "It would be catastrophic."

Dams are critical in Iraq for generating electricity, regulating river flow and providing irrigation. Water is a precious commodity in this largely desert country of 32.5 million people. The decline of water levels in the Euphrates over recent years has led to electricity shortages in towns south of Baghdad, where steam-powered generators depend entirely on water levels.

Water has been used as a weapon in the past. After Shiite Muslims rose up against then-President Saddam Hussein after the 1991 Gulf War, he retaliated by drying out parts of wetlands in the south of the country that had once generated farming revenues for its Shiite inhabitants.

Water is not the first resource the Islamic State group has narrowed in on as it swept over much of northern and western Iraq and parts of neighboring Syria the past months. The group has captured oilfields and pipelines in Syria and has sold off crude oil, helping fund its drive across both countries.

If it captures the dams, the militants are likely to try to use its electricity and water resources to build up support in nearby areas it controls, where residents often complain of shortages. Or it could try to snarl electricity service elsewhere.

Any disruption to the Mosul Dam "would destabilize the electricity system of northern Iraq," added Paul Sullivan, an economist and Middle East expert at National Defense University in Washington. "This station is an integral part of the entire electricity grid of Iraq."

The Associated Press contributed to this report.