Risks include a burgeoning jihadist insurgency in areas retaken from the group more than two years ago, including Diyala province, where Iran-backed militias have exacerbated matters by engaging in collective punishment. In a sense, the battle ended where it started. On 6 June 2014, IS forces staged a diversionary attack in northern Mosul that was intended to draw Iraqi forces away from a prison break in a town called Badush, 16km (10 miles) north-west of the city. Just over three years later, IS made its last stand there.
Washington Institute reports in its article Mosul Defeat a Blow to IS, but Not the End that the reduction of the last IS pocket in Mosul was a true battle of annihilation. Unlike in prior battles, such as Tikrit and Falluja, the siege did not witness a breakout or withdrawal by IS fighters. Estimates suggest that IS fielded about 1,000 fighters in eastern Mosul and another 2,000 in western Mosul. The vast majority of them will have been killed in the intense fighting, making the battle the most costly defeat suffered by IS.
Iraqi Prime Minister Haider al-Abadi can expect to be strengthened by the liberation, as will key commanders such as Lt.-Gen. Abdul Wahab al-Saadi of the Counter-Terrorism Service. Rival pro-government forces, such as the Hashd al-Shaabi (Popular Mobilization units, or PMU), will seek to stress their role in peripheral operations such as the drive to the Syrian border.
With an eye towards Iraq's 2018 national elections, Iranian-backed Shia PMU commanders such as Abu Mahdi al-Muhandis -- a U.S.-designated global terrorist -- and Hadi al-Ameri will want to share the political limelight with Prime Minister Abadi.
In Mosul, there will be a major requirement for reconciliation and reconstruction. The city may not be included in forthcoming provincial elections because of the difficulty of holding polls in a post-conflict environment, but there is an urgent need for a higher co-ordination council to oversee it and other parts of Nineveh province. One option may be the appointment of a popular and trusted figure such as Gen. Saadi as an interim co-ordinator.
Transitional justice is a key issue, because IS fighters from Mosul and its rural outskirts may have blended back into the population and public demand for vengeance will be strong. Mosul also needs physical reconstruction, a task that has barely begun even in the parts of the city that were retaken eight months ago at the battle's outset. On 5 July, Lise Grande, the UN Humanitarian Co-ordinator for Iraq, estimated that emergency reconstruction of the city would cost more than $1bn.
New military challenges loom for Iraq even as the battle ends in Mosul. Just 65km west of the city lies the smaller Tal Afar, which remains under IS control. Forces from the Mosul battle are already being dispatched to Tal Afar to begin the clearance of that city. Covering less than one-eighth the surface area of Mosul, Tal Afar is a long-term stronghold of IS and may still require weeks or months of fighting to liberate.
Some 290km to the south-west of Mosul, IS also holds a string of towns in Anbar province along the Iraqi portion of the River Euphrates. Collectively known as al-Qaim, these towns are closely connected to the remaining IS strongholds in the Euphrates valley in Syria, such as Raqqa and Deir al-Zour. Unless IS suffers a catastrophic collapse of military capacity -- which is possible at this culminating phase of the campaign -- then the Tal Afar and al-Qaim battles could still consume much of the rest of 2017.
There is also evidence that the jihadist group has seamlessly made the transition back into an insurgent movement. A burgeoning IS insurgency has flared up in areas that were retaken from it over two years ago. They include Diyala province, where Iranian-backed militias have thrown fuel on the fire by undertaking collective punishment of the Sunni Arab community, human rights campaigners say.
In Mosul itself, we can see the future of the IS presence in the way the movement has adapted its operations within recently liberated areas. Timed to coincide with the start of Eid al-Fitr celebrations, IS launched five attempted mass casualty bombing attacks in eastern Mosul on 23-24 June, and the group briefly overran a small area of western Mosul on 26 June with a large-scale raid involving more than 30 fighters. IS is likely to use these kind of tactics -- and large bombings of Shia pilgrims near Baghdad during religious festivals later this year -- to offset the military losses they have suffered. Iraq's battle against IS is set to shift from the open battlefield to the shadowy realm of counter-terrorism raids in the cities, deserts and borders.