QAYYARA AIRBASE, Iraq (Reuters) - The U.S.-led war on Islamic State has depleted the group’s funds, leadership and foreign fighters, but the biggest battle yet is expected later this year in Iraq’s northern city of Mosul, where Abu Bakr al-Baghdadi declared his “caliphate” two years ago.

U.S. soldiers gather in the town of Gwer, northern Iraq August 31, 2016. REUTERS/Azad Lashkari /File Photo

The jihadist insurgents have lost more than half the territory they seized in Iraq and nearly as much in neighboring Syria, but still manage to control their twin capitals of Mosul and Raqqa, symbols of the state they sought to build at the heart of the Middle East.

Military and humanitarian preparations are now in full swing to retake Mosul, the largest city under the ultra-hardline group’s control. American troops are establishing a logistics hub to the south, while the United Nations warns of the world’s most complex humanitarian operation this year.

Iraq’s recapture over the summer of Qayyara airbase and surrounding areas along the Tigris river 60 km (nearly 40 miles) south of Mosul have set the stage for a big push on the city, which commanders say could start by late October.

Whether Islamic State makes a final stand in Mosul or slips away to fight another day remains in question, but Baghdad expects a fierce battle and the international coalition backing it is preparing for one.

The densely populated river valley may hold obstacles for the military, though Islamic State appears to be putting up relatively little resistance, possibly to conserve fighters for a showdown in Mosul where their forces are estimated at between 3,000 and 9,000.

Hardcore fighters have likely slipped out already through the desert and into Syria, while many top leaders and foreign fighters have been killed in targeted air strikes, according to Major General Najm al-Jabouri, the Mosul operation’s commander.

He told Reuters that victory by year’s end would be easy, in keeping with pledges by Prime Minister Haider al-Abadi.

“We will go to Mosul, they will go to Tel Afar. We will go to Tel Afar, they will go to Baaj,” said Jabouri, referring to IS-controlled districts 70 km (44 miles) and 140 km (87 miles)west of Mosul, respectively, which can be used to reach Syria.

“We will go to Baaj, maybe. It depends on the situation in Syria. They can get to Syria but the situation there is not like before. It is not a safe haven for them now.”

TURNING TIDE

Lieutenant General Vincent Stewart, Director of the U.S. Defense Intelligence Agency, said on Thursday he expected the Mosul operation could unfold in the next two or three months but that it would be long and difficult.

“Urban warfighting is not easy and this is a large city that has had at least two years to prepare to defend its position ... It’s going to be a multi-dimensional fight,” Stewart said at a national security summit in Washington.

The war against jihadist insurgents in the Middle East has ebbed and flowed but there is a palpable sense in the region that the tide has turned against Islamic State.

In the past year and a half, the group has lost swathes of territory and strategic outposts. In Iraq it was driven out of Tikrit and Sinjar in the north, the oil refinery town of Baiji, and finally Ramadi and Falluja in western Anbar province, the heart of the insurgency following the U.S.-led invasion in 2003 that toppled Saddam Hussein.

In northern Syria, U.S.-allied Kurdish militia of the People’s Protection Units (YPG) have taken vital territory and border crossings below the frontier with Turkey after capturing Kobani and later taking Tel Abyad, a key supply line for the jihadist capital Raqqa further south. The YPG has expanded its territory west of the Euphrates, seizing Manbij last month.

Meanwhile Turkey, backing Syrian rebels, this month cleared Islamic State from its southern border by seizing some 20 villages while Libyan government forces are close to flushing IS insurgents from holdouts in Sirte.

Amid those territorial losses, Islamic State has claimed credit for a surge in global attacks this year beyond its main Middle East theater. European countries remain on alert for additional strikes based on undisclosed information.

Nonetheless, the U.S. military has said Iraq is on track to retake Mosul later this year. Over the past two weeks, convoys of sophisticated engineering vehicles have been seen approaching Qayyara airbase, which Islamic State wrecked before withdrawing in July.

Repairing it to help supply the 20,000 to 30,000 Iraqi troops expected to be used in the campaign could take another two months. Until then, forces trained by the U.S.-led coalition are amassing further afield.

Mosul fell to Islamic State in June 2014 when Iraqi security forces, riddled with corruption and sectarianism despite billions of dollars in U.S. aid, dropped their weapons and fled from the insurgents.

Slideshow ( 5 images )

KURDISH AND SHI’ITE FORCES

Kurdish peshmerga forces, entrenched east, north and northwest of Mosul since 2014, will help tighten the noose around the city but might not enter central districts to avoid aggravating political sensitivities.

After retaking 11 villages southeast of Mosul last month, they are now eyeing eastern Christian and Shabak villages long abandoned by minority communities the group seeks to eliminate.

The peshmerga’s role is complicated by tensions with the central government, which claims territory the Kurds have taken from IS and effectively annexed to their autonomous region. The Kurds say Baghdad is not forthcoming about its military strategy for Mosul or its plans to manage it after the battle.

“If we do not prepare the politics of it, we may not succeed in the military plan or we may succeed in the military plan but lose the political plan and that would be disastrous,” Falah Mustafa Bakir, the head of Kurdistan’s Foreign Relations Department, told Reuters last week.

The participation of the Hashid Shaabi, a government umbrella for mostly Shi’ite militias, is also unresolved. Powerful commanders have pledged to take part, despite fears among Mosul’s Sunni leaders and residents of rights abuses.

Prime Minister Abadi said this week the demands of the battle would dictate the disposition of forces but that no decision had been made to bar the Hashid.

Confrontation that inflames sectarian tensions between Shi’ite-led government forces and the Sunni jihadists of Islamic State risks turning Mosul into a “bloodbath”, according to a Western diplomat in Baghdad.

HUMANITARIAN CRISIS

The Mosul operation has also triggered large-scale humanitarian planning, with the U.N. predicting up to one million people could flee the city in all directions.

The Kurds expect half of those leaving will head toward their territory, which already struggles to accommodate more than one million displaced people.

Regional authorities, fearing a new wave will exacerbate demographic and security concerns, aim to settle new arrivals in camps outside of main cities.

In the best-case scenario, though, there is only enough land and funding for about 450,000 people, according to a senior U.N. official, raising the prospect of housing others in unused buildings or abandoned villages.

“If there is mass displacement, there could be shantytowns in the disputed border areas because the plan for camps doesn’t accommodate them all,” said Tom Robinson, director of Rise Foundation, which analyses Iraq’s humanitarian crisis.

Aid workers say the authorities are limiting the construction of new camps to discourage displacement. In fact, the military is urging residents to shelter in place as it advances, but that will only be feasible if fighting doesn’t lay waste to homes and infrastructure as it has before.

Jabouri, the top Iraqi commander, dismissed concerns that such a scheme jeopardises civilians’ safety, saying: “What does it mean if some areas receive mortars? That’s not the end of the world. We are in Iraq, not in Switzerland.”