As difficult as it will be to drive Islamic State from its last major stronghold in Iraq, there is little doubt that the militants in Mosul will be defeated. The question is whether they will be back one day.
Previous attempts to pacify the city, once one of Iraq's largest and most diverse, devolved into ethnic and sectarian infighting that made fertile ground for the militants to stage a comeback.
"We have made this same mistake at least twice in Iraq," said Kenneth M. Pollack, a Middle East specialist at the Brookings Institution, a Washington think tank. "We don't prepare adequately for the political context, and the result, as I warned in 2002, is chaos, warlordism and civil war."
There is little trust between Sunni Arabs, who dominate in Mosul and the rest of Nineveh province, and the Shiite Muslim-led government in Baghdad. Relations are equally fraught with Iraq's semiautonomous Kurdish region, which Arabs fear will use the fight against Islamic State to extend its territorial reach into Nineveh – just as it has done in the oil-rich province of Kirkuk.
The offensive is being waged by an array of forces: the Iraqi army and federal police; Kurdish fighters known as peshmerga; local Sunni, Christian, Yazidi and Shabak fighters; and members of Shiite militias, some of them backed by Iran.
For now, they are united by a common enemy — but they have very different ideas about what should happen after Islamic State is gone.
Nineveh's former governor, Atheel Nujaifi, who assembled a force of several thousand trained by Turkish military advisors, has argued that the province should be given greater autonomy to run its affairs – much like the Kurdish region to the north and east.
The Kurdish leader, Massoud Barzani, has suggested that Nineveh be divided into three smaller provinces and referendums held to decide whether they will be affiliated with Baghdad or the Kurdish government in Irbil.
Shiite leaders in Baghdad want to keep Nineveh intact, but some are open to the idea of giving more power to the province.
What could prove even more problematic are the many local fissures – social, political, tribal – that are bound to surface as leaders set about the contentious business of standing up a police force, restoring services, getting displaced people back into their homes and rebuilding neighborhoods after what is expected to be a drawn-out and destructive fight.
If such differences can't be bridged, it could reignite the frustration and fear among Sunni Arabs that propelled Islamic State's rapid spread in Iraq, and that of Al Qaeda before it.
Just look to 2003: Baghdad was then a stronghold of Saddam Hussein's Baath Party with a proud history of military service dating back to the Ottoman Empire. But after the U.S. invaded, the interim administration led by L. Paul Bremer III disbanded the Iraqi army in a purge of regime loyalists, sending many high-ranking officers and soldiers into the arms of the insurgency.
Gen. David H. Petraeus, who as commander of the 101st Airborne Division was responsible for Mosul in 2003, said his attempts to foster reconciliation between local Sunnis and the country's ascendant Shiite majority were undone by Iraqi officials in Baghdad who continued to enforce Bremer's order barring members of the Baath Party's upper echelons from holding government jobs, even after U.S. diplomats started pressing for more inclusiveness.
"At a certain point, [Sunnis] realized they had an incentive to oppose the new Iraq rather than to support it, and that obviously is a very dangerous situation," said Petraeus, who went on to command all U.S. forces in Iraq.
Those disgruntled former military officers and tribal leaders would later make common cause with religious extremists who came to Iraq from other countries to fight the U.S., giving rise to the group Al Qaeda in Iraq.
The Iraqi forces that were brought in to fill the security vacuum in Nineveh were primarily peshmerga who had fought against Hussein.
"The people of Mosul saw this as Kurdish occupation under a very thin guise of it being the Iraqi army," said Michael Knights, a Boston-based fellow at the Washington Institute for Near East Policy.
To make matters worse, analysts say, Mosul received short shrift from the U.S. and Iraqi authorities, who were more focused on securing Baghdad and Sunni strongholds in neighboring Anbar province. As a result, the militants were able to regroup and launch counteroffensives in the north of Iraq.
U.S. commanders credit an uprising by Sunni tribal leaders that began in Anbar for helping to turn the tide against Al Qaeda in 2007 and 2008.
But the prime minister at the time, Nouri Maliki, never trusted the so-called Sunni Awakening, which included former insurgents, and had many of them arrested. After the U.S. military withdrawal in 2011, prominent Sunnis were purged from the government and military, leading to waves of protests in Sunni parts of the country.
By the time Islamic State fighters swept across the border from Syria in 2014, morale in Mosul was so low that many members of the security forces shed their uniforms and fled.
Some city residents initially welcomed the militants, seeing them as protection from a sectarian government in Baghdad and an expansionist Kurdish region. But two years under Islamic State's brutal rule changed the view of many.
When Iraqi counter-terrorism commandos punched their way into eastern districts of Mosul this month, they were greeted as heroes by some residents who flashed victory signs and planted kisses on their cheeks.
This presents an opportunity for Maliki's successor, Prime Minister Haider Abadi, to break the cycle of instability in Mosul, analysts say.
Iraqi leaders and their foreign allies appear to have learned from past mistakes. Peshmerga and Shiite militia fighters, accused of abuses against Sunni Arabs during previous campaigns, are deployed in villages around Mosul and not inside the city proper, for example.
But officials in Baghdad have said little about how they intend to secure and govern Mosul after Islamic State is gone.
In the two years since he assumed office, Abadi has shown a willingness to work with groups once seen as adversaries. But the premier has struggled to exert authority in the face of opposition from fellow Shiites – including Maliki. Many of his proposed reforms, including plans to establish a national guard that could bring more Sunnis into the armed forces, have languished in parliament.
Abadi's government is now under attack by members of his own parliamentary bloc who engineered the departure of two senior Cabinet members – Defense Minister Khaled Obeidi, a Sunni from Mosul, and Finance Minister Hoshyar Zebari, a Kurd – within the space of a month through no-confidence votes.
"The prime minister has done a good job so far of bringing Iraq back from the brink," said Sajad Jiyad, managing director of Al Bayan Center for Planning and Studies, a Baghdad think tank. "But the competitive and dysfunctional nature of Iraqi politics means there are politicians who will attempt to disrupt progress to undermine him and whip up sectarian and ethnic tensions for political gain."
Brett McGurk, President Obama's envoy to the coalition fighting Islamic State, acknowledged at a recent news conference that much remains undecided on the political front. But he said if Iraqis had tried to resolve every issue before launching the military campaign, the militants would "remain in Mosul for the foreseeable future and perhaps forever."
The plan, he said, is to restore to power the current governor, Nofal Hammadi, and provincial council, with the addition of representatives from Baghdad and Irbil. They will then decide the way forward in consultation with the United Nations and the coalition.
That approach worries Pollack, who was recently in northern Iraq and met key players.
"I would say that all sides are reasonably confident that things are going to work out their way," Pollack said. "That should tell you that someone is inevitably going to be disappointed … and we don't know how they are going to react."
The threat isn't just internal. Turkey and its regional rival, Iran, are both heavily invested in what happens there and could intervene if they believe their interests -- or those of proxies -- are at risk.
Knights, however, said there was logic to the government's approach.
"What we've realized over the years is that you shouldn't expect a post-conflict stabilization plan for a city in Iraq to look like the plan for the Olympic Games, with 200 working groups and 500,000 pages of detailed text and annexes," he said.
What is important, he said, is to have a strategy to keep all the sides talking.