Shiite Popular Mobilization Forces members clash last month with Islamic State militants in Tal Afar, Iraq. (Reuters)

Iraqi security forces have freed most of northern Iraq from the grip of the Islamic State. But U.S. and Iraqi officials warn that thousands of militants remain in the country and are ready to wage a ferocious fight in a desert region bordering Syria.

The bulk of the war against the Islamic State was finished when Iraqi security forces reclaimed the cities of Mosul and Tal Afar this summer. But the battle looming in western Anbar province is expected to be one of the most complex to date. 

The vast region will be difficult to surround, and clearing it will probably involve coordination among the U.S.-backed forces and the Syrian regime, Russia and Iran. U.S. officials also believe that the Islamic State’s leader, Abu Bakr al-Baghdadi, is hiding there.

Iraqi forces retook Tal Afar in just eight days, but officials say that was an anomaly and not a new rule. Shiite militias encircled the city for eight months while U.S.-led airstrikes pounded weapons facilities and targeted groups of fighters and their commanders before the ground operation began late last month.

“While I’d like to say that we would see this elsewhere in Iraq and Syria, we’re not really planning for that,” said Lt. Gen. Stephen Townsend, who until last week was the commander of coalition forces in Iraq and Syria. “We’re planning for tough fights ahead.”

Those fights also will include the battle for the city of Hawija, whose location in north-central Iraq has made it an ISIS launchpad for small but deadly raids in nearby cities.

But the coming fight for Hawija has been complicated by a political dispute. Kirkuk, the province in which Hawija lies, historically has been claimed by both Kurds and Arabs. In 2014, Kurdish peshmerga fighters secured the city of Kirkuk against the Islamic State advance and have remained there since then.

Last month, the Kirkuk provincial council voted to participate in a referendum on Kurdish independence planned later this month, raising the possibility that Kirkuk would become part of a fully autonomous Kurdish nation. Iraq’s central government, along with the United States, Iran and Turkey, strongly oppose the referendum.

Securing Hawija would go a long way toward preventing the Islamic State from staging attacks, said Najmaldin Karim, who has served as the governor of Kirkuk but on Thursday was voted out by Iraq’s parliament because of his support for the Kurdish referendum. He has vowed to stay in his position.

“They can do significant damage to other places from Hawija,” he said of the Islamic State, adding that waiting until now to retake the city was “illogical.” 

Once home to a majority Sunni population of about 100,000, the city has been mostly cleared of civilians. Military planes recently began dropping leaflets promising the estimated 20,000 still in the city that their liberation is near and advising them to avoid gatherings of Islamic State militants.

An American counterterrorism official, who spoke on the condition of anonymity to discuss classified battlefield assessments, said some 1,000 Islamic State fighters still in Hawija maintain networks of Sunni tribal sympathizers as well as supply lines running from Anbar into Syria. 

“Does Tal Afar indicate anything that these battles are going to be easy? I don’t think so,” the official said. “There is a lot of fighting left to do.”

ISIS controlled about one-third of Iraq in 2014, but its territory has shrunk dramatically since Iraq’s military regrouped under U.S. supervision and Iranian-backed Shiite militias mobilized to reclaim towns and villages. Today, the Islamic State holds only about 10 percent of its self-declared caliphate in Iraq.

Hawija has been largely encircled for a year, by Kurdish peshmerga fighters to the north and Shiite militias and regular Iraqi army forces from the south. Iraq’s prime minister, Haider al-Abadi, faces the task of deciding which force will take the lead — a decision likely colored by the Kurdish desire to include Kirkuk in their future state.

“The issue of delaying the Hawija battle has been too related to who will do it and who can claim credit for it, while the people of Hawija suffer,” Karim said.

Though their forces are near Hawija, peshmerga officials say they have not received any orders to prepare for the fight.

“We have forces ready for Hawija, but so far there are no orders, and we don’t know if we will participate,” said Brig. Gen. Halgurd Hikmet, a Peshmerga spokesman. Peshmerga soldiers played secondary roles in the fight for Tal Afar and the much longer battle for Mosul, securing areas around both to prevent militants from escaping or staging incursions into reclaimed lands.

Townsend said one of the keys to the rapid success in Tal Afar was that several Iraqi military branches attacked from five fronts, quickly collapsing the Islamic State’s lines of defense and forcing the militants into a scattered resistance.

During the halting three-year campaign to clear Iraq of the Islamic State, Abadi has opted to retake major cities one at a time, giving a military that collapsed in the face of the Islamic State onslaught in 2014 time to rebuild.

A senior Iraqi counterterrorism service officer, who spoke on the condition of anonymity to discuss sensitive military planning, said some commanders are urging Abadi to launch Hawija in tandem with the effort to retake the Anbar towns of Qaim, Ana and Rawa — a chain of Sunni enclaves in the Euphrates River Valley.

It is largely seen as the Islamic State’s last stand in both countries. 

A spokesman for Iraq’s military declined to discuss force composition for Hawija but said there are enough troops to stage the battle for the city and for Anbar concurrently.

That fight took on new urgency when the Lebanese Hezbollah movement announced a deal last week to move some 300 Islamic State fighters and their families from western Syria to the Islamic State-controlled town of Bukamal on Iraq’s border.

Abadi and U.S. officials recoiled at the deal, saying it reinforced the Islamic State’s presence in the Syrian province of Deir al-Zour and undermines Iraq’s security. The United States launched airstrikes to halt the advance of a column of buses to Bukamal by cratering roads and a small bridge. 

Last week, Iraqi officials from Anbar and Syrian activists said part of the convoy had made it over the border to the Iraqi towns in the Euphrates River Valley, confirming the worst fears of Iraq’s leadership and its U.S. military allies.

“We are considering changing the plans for western Anbar based on these developments,” said Saeed al-Jayashi, a government adviser to the Iraqi joint operations command.

On Monday, armored units from Iraq’s army began to deploy to military bases in Anbar.

Bukamal is just across the border with Qaim, and senior Islamic State leaders are believed to be in both towns. Townsend said he believes that Islamic State leader Baghdadi is moving between hideouts in the Euphrates valley, contradicting Russian claims that he is probably dead.

The battle on the Iraqi side of the border is also likely to be complicated by the convergence of interests in the area. Forces that are part of a Syrian-Iranian-Russian alliance have begun advancing on Deir al-Zour province and could push Islamic State militants into Iraq. The close-quarter fighting also will require the United States and Russia to ensure that the forces they are backing don’t come into conflict.

According to a Pentagon assessment, between 5,000 and 10,000 militants are in the area.

U.S.-backed Syrian forces announced their offensive in the oil-rich province Sept. 9, heightening fears of clashes among forces supported by countries with divergent views over its future.

The close-quarter fighting also will require the United States and Russia to ensure that the forces they are backing don’t come into conflict.

“I’m reasonably confident that we'll be able to work through this,” Townsend said, adding that there have already been conversations with the Russians to delineate sectors for the coming battle. “Everyone that’s converging down there is trying to defeat ISIS as a first priority, and we’ll use that to our advantage to work through it.” 

Warrick reported from Washington.