Get breaking news alerts and special reports. The news and stories that matter, delivered weekday mornings.

IRBIL, Iraq — After almost nine months of fierce fighting, the campaign to recapture Mosul from ISIS is drawing to a bitter end in the ruins of the city's historic quarter, but the struggle for Iraq's future is far from over.

Aside from Mosul, across the border in Syria a battle is raging to dislodge ISIS from Raqqa, the second capital of its self-declared caliphate. Fighting will push down the Euphrates valley to Deir al-Zour, the jihadis’ last big urban stronghold.

But the fall of Mosul also exposes ethnic and sectarian fractures that have plagued Iraq for more than a decade.

The victory risks triggering new violence between Arabs and Kurds over disputed territories or between Sunnis and Shi’ites over claims to power, egged on by outside powers that have shaped Iraq’s future since the 2003 U.S.-led invasion toppled Saddam Hussein’s Sunni minority-rule and brought the Iran-backed Shi’ite majority to power.

For Iraq, stunned by the blitz on Mosul by ISIS in 2014 and the collapse of its army, victory could thus turn out to be as big a problem as defeat.

The federal model devised under the Anglo-American occupation and built on a power-sharing agreement between Sunnis, Shi’ites and Kurds collapsed into ethno-sectarian carnage spawned by the al Qaeda precursors of Islamic State.

Iraqi police celebrate gains in Mosul, Saturday. AHMED SAAD / Reuters

In the three years since jihadis swept across the border from Syria where they had regrouped in the chaos of the rebellion against Syrian President Bashar al-Assad’s rule, ISIS was the rallying point uniting a fractured Iraq.

But now that the group faces military defeat, the unity that held Iraq together is starting to come apart.

After eight months of combat that has left parts of the city in ruins, killed thousands of civilians and displaced nearly one million people, Iraqi officials say they have almost regained full control of Mosul.

ISIS militants threw themselves into the Tigris river on Sunday, trying to flee as Iraqi forces reached the riverbank, bringing them to the verge of victory.

The militants have been driven from all but a patch of territory on the western bank of the Tigris bisecting Mosul, where they have staged a last stand in the narrow alleys of the Old City.

Plumes of smoke rose over the Old City on Sunday and the decaying corpses of ISIS fighters lay in the streets. Scattered bursts of gunfire could be heard and several airstrikes were carried out.

Iraqi military spokesman, Brigadier General Yahya Rasool, told state TV that 30 militants had been killed attempting to get away by swimming across the Tigris.

Let our news meet your inbox. The news and stories that matters, delivered weekday mornings. This site is protected by recaptcha

No post-battle plan

One challenge is the future of Mosul itself, a city traumatized by ISIS’ brutal rule and shattered by the latest U.S.-backed offensive, with thousands dead and nearly one million people displaced.

Western, Iraqi and Kurdish officials say they are astonished that Iraqi authorities neglected to prepare a post-battle plan for governance and security.

Iraqi women and children fleeing the last fighters of ISIS in Mosul on Saturday. FADEL SENNA / AFP - Getty Images

A high-level committee formed by the Kurdish region, the Baghdad government and a U.S.-led military coalition to help Mosul leaders rebuild the city had never convened, they said.

"Prime Minister (Haider) al-Abadi kept dragging his heels. Every time we raised this issue with him, he said, 'Let’s wait until military operations are over'," said Hoshyar Zebari, an internationally respected former finance and foreign minister.

"A whole city is being decimated. Look how much the government is contributing, as if they don’t care."

The first indication of possible future conflict came when Masoud Barzani, president of Iraq's autonomous Kurdish region, announced a Sept. 25 referendum for an independent state.

Another omen was a push by Iran-backed Shi'ite militias, grouped under the government-run Hashid Shaabi, to deploy alongside Kurdish areas and advance towards the Syrian border, motivated by Iran's desire to join Iraq and Syria and establish a corridor from Tehran to Beirut.

"Today the highway of resistance starts in Tehran and reaches Mosul, Damascus and Beirut," Ali Akbar Velayati, the top adviser to Iran's Supreme Leader, said last week.

Jihadi fighters

All this comes against a backdrop of simmering rivalries between regional powers Iran and Turkey, and above all declining U.S. influence and Iran’s vigorous attempts to consolidate its control in Iraq.

While the administration of U.S. President Donald Trump regards Syria and Iraq purely in terms of the military campaign to destroy ISIS, local jihadi fighters will simply melt back into the population, and could regroup in a new insurgency.

Sunni and Kurdish leaders in and around Mosul largely agree with this grim prognosis, alarmed that Abadi has refused even to discuss the future governance of Mosul, and suspecting that Iran is calling the shots.

The disputed territories stretch along an ethnically mixed ribbon of land dividing the autonomous Kurdish area in the north of Iraq from the Arab-majority part in the south - more a minefield than a mosaic - at a time when both the Kurds and Sunni Arabs are giving up on Shi’ite rule in Baghdad.

Smoke is seen over Mosul Sunday after an airstrike by U.S.-led forces. AHMAD AL-RUBAYE / AFP - Getty Images

Atheel al-Nujaifi, who was Nineveh governor when the provincial capital Mosul was captured in 2014, says: “We are back to where we were before Mosul fell, (because) there is an idea among the hardline Shi’ite leadership to keep the liberated areas as loose areas, with no (local) political leadership, or security organizations, so they can control them”.

Moderate Shi’ite leaders, among whom he counts Abadi, are wary of a winner-take-all logic of victory, fearing this “could lead to the creation of radicalism again and they know this would destroy not only Iraq but the Shi’ites”.

The problem, he believes, is that Iraqi Shi’ism is badly fractured, helping Iran control almost all its factions.

The former governor, a Sunni who now has at his command an armed force trained by Turkey, says he is bowing out of office but not politics. He acknowledges there is a lack of mainstream Sunni leaders, but blames Baghdad for making sure none emerges.

Whither the Sunnis?

Talk of Kurdish secession has sparked discussion of whether Sunni Arabs should set up a separate state, though most officials say this is not practical, because: Sunni territory lacks the oil base the Shi’ites and Kurds have; the experience of ISIS would hover like a specter over any new entity; and Sunnis are too intermingled across Iraq.

Some Sunni and Kurdish leaders believe one solution is to make Mosul a self-governing region like Kurdistan, with smaller units of self-rule to accommodate the plethora of minorities, which they say is permitted by the constitution.

“Before, the Sunnis were very sensitive to believing (devolution) would lead to secession, to the breakup of Iraq but now they’re coming to terms with it,” says Zebari.

The Sunnis are not the only ones who repudiate Baghdad's Shi’ite-dominated government. The northern Kurdish region has called a referendum to move from autonomous self-rule to an independent state.

Kurdish leader Barzani told Reuters timing for independence after the vote was “flexible but not open-ended”.

Yet there is growing concern the real purpose of the referendum is not immediate secession, but to strengthen Kurdish claims over the disputed territories, such as the oil-rich region and city of Kirkuk, whose future has been in play for over a decade.