ERBIL, Iraq (Reuters) - After almost nine months of fierce fighting, the campaign to recapture Mosul from Islamic State 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 IS 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 Islamic State 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.

In the three years since the 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, IS 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.

NO POST-BATTLE PLAN

One challenge is the future of Mosul itself, a city traumatized by Islamic State's 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.

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 IS, 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.

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 Islamic State 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.

"WE LOST HOPE AND FAITH"

Zebari, a senior official in Barzani’s Kurdish Democratic Party who devoted over a decade in Baghdad trying to make power-sharing work, said the time was ripe for independence.

“We lost hope and faith in the new Iraq that we had built. The government has failed us on each and every constitutional provision and article to establish a new country with equal citizenship, with no discrimination, with partnership. All those dreams have evaporated,” he told Reuters.

The problem, he says, is that senior Iranian officials have left no doubt their priority – a corridor for Shi’ite forces carved through the north and policed by Shi'ite recruits – trumps everything else.

"They are breathing down our neck all along the Kurdish frontline from Sinjar to Khanaqin," he said.

"So far we have been accommodating, patient, coordinating to prevent skirmishes or flashes but this is building up."

(For a graphic on destruction in Mosul's old city, click http://tmsnrt.rs/2u0o515)