The outcome of Iraq's military campaign against the Islamic State of Iraq and the Levant is beyond doubt. ISIL was never the mythical fighting force that many people assumed, and it was always just a matter of time until the Iraqi army would regroup and reorganise.
With its vastly superior numbers, armaments, funding and international support, the military will push ISIL out of its last redoubts within Iraq's territory, possibly before the end of this year.
Without minimising the seriousness of the military campaign and the sacrifices of the individuals in uniform who are risking so much to liberate their country from ISIL, Iraq's more determinant challenges will lie elsewhere.
It is now standard fare among analysts that Iraq's long-term objective must be to prevent the emergence of "al-Qaeda 3.0" and that the Iraqi state must enact a number of common-sense measures to prevent the jihadists from remobilising within a few years.
READ MORE: Mosul Battle puts Iraqi civilians 'at heightened risk'
While a short-term military victory against ISIL might be near, I am not remotely confident that the Iraqi state will establish the institutions and mechanisms that are necessary to protect its people.
Iraq will have to complete its military campaign without destroying Mosul, while at the same time establishing some semblance of the rule of law and protecting its population from retribution.
Most countries would find these challenges daunting and, given Iraq's track record, there is little cause for optimism here. While past failures have been depressing enough in their own right, the stakes in Mosul are much more significant, given the city's size and historical significance.
Getting these issues wrong in Mosul will have far greater repercussions than they have elsewhere.
In the context of a near-total absence of government oversight, regular and irregular forces have looted and burned people's homes, tortured and sometimes even executed detainees over the past two years, often well after ISIL' forces on the ground were defeated.
Iraqis are living through intense times. The country's social relations have been remarkably resilient in the face of a constant barrage of violence. Nevertheless, because of the context that we are living in, developments on the ground are now automatically interpreted through a sectarian lens by just about everyone.
Military realities make it inevitable that Mosul will suffer significant physical damage in the coming weeks and months, which will cause many locals to resent Baghdad.
Put in crude, sectarian terms, many local Sunnis will assume that their city was purposely reduced to rubble by Shia-led forces to punish them and possibly even encourage them to leave and never return.
For people on the ground, this will be a fairly easy narrative to believe given developments over the past two years. In the context of a near-total absence of government oversight, regular and irregular forces have looted and burned people's homes, tortured and sometimes even executed detainees over the past two years, often well after ISIL forces on the ground were defeated.
While this type of behaviour is not representative of the security service's overall conduct, the abuses that have taken place have been very well documented, and there has hardly been any accountability for those responsible.
Less perniciously, perhaps, but just as importantly, the government's response to the tens of thousands of people who have been displaced by the fighting in places such as Tikrit, Ramadi and Fallujah has been highly deficient, with thousands being forced to languish in the open air with almost no provision.
These totally unnecessary developments have given considerable ammunition to Iraq's enemies as they cast doubt on the country's capacity to survive as a single nation.
In the battle for Mosul, given what is at stake, the government has no choice but to take this issue far more seriously. The challenge for the Iraqi government will be first to control the behaviour of its military, the police and in the Popular Mobilisation Units, who in other contexts have unnecessarily damaged property and infrastructure and committed horrific abuses against ordinary citizens.
This will require oversight and accountability measures of the type that have been lacking in Iraq in recent memory.
The Iraqi government will also have to counter the sectarian narrative by clearly explaining the precautions that have been taken to prevent unnecessary damage to the city and to protect its people during the military campaign.
In the past, the Iraqi government has responded to allegations of abuse either by not reacting at all, or by downplaying the damage caused and its significance.
Even where the government successfully liberated Tikrit, allowing the vast majority of its inhabitants to return unmolested, it did not adequately carry that message, leaving the narrative to be depicted in starkly negative terms.
Iraqi Prime Minister, Hayder al-Abadi, appears to be taking this issue more seriously than in the past. He has issued clear instructions to all groups involved in the fighting and has delivered convincing statements designed to reassure the local population about their future.
However, the problem since 2014 has not been an absence of good intentions but the failure to establish the type of oversight mechanisms that would cause for good intentions to be reflected in reality.
Given past performance on both issues, there is little cause of optimism that the government will rise to the challenge.
READ MORE: The day after the battle for Mosul
After the battle against ISIL in Mosul has been won, and even if no major abuses take place, there is still a risk of the terrorist network rising again out of the ashes, as it did from 2009 to 2014.
After al-Qaeda's first defeat in 2008, they were able to exploit Iraq's decrepit security arrangements, its corrupt politics and its ineffectual justice sector to re-establish their racketeering networks, to rearm and to intimidate and assassinate their opponents over a period of years.
They did so safe in the knowledge that state institutions were incapable of investigating, arresting, prosecuting or punishing anyone apart from the weak and vulnerable. The only way to counter this and prevent it from recurring will be to reform the courts, the police and the country's intelligence sector to ensure that they are capable of monitoring, investigating and prosecuting terrorist and criminal networks as they seek to re-establish themselves.
Establishing the rule of law in Iraq will be far more difficult than people realise for at least two reasons. First, the country's legal framework is essentially non-existent. There are no laws to govern the Ministry of the Interior - apart from a "secret" Baath-era law that no one appears to have a copy of - or to control any of the very many intelligence agencies that were created since 2003.
All function in the absence of clear mandates, operating procedures or oversight. Enacting the necessary legislation to make each of these bodies more accountable and efficient would be a monumental task for any country.
Which is why it is so unfortunate that the body responsible for enacting this legislation, the Iraqi parliament, is the most ineffectual of all state institutions. Fuelled by a highly deficient electoral law, parliamentarians openly abuse their positions, engaging in corruption and even bragging at how much wealth they have accumulated.
READ MORE: Will Fallujah put an end to ISIL in Iraq?
It would be foolish to assume that the parliament is either capable or willing to enact the type of legislation at issue, mainly because the logical result of any such action would be that a large proportion of parliamentarians would end up in jail.
Therefore, if the only path to establishing security and the rule of law in Iraq is through parliamentary reform, then the only avenue of opportunity for genuine reform is to replace the current parliamentarians in the 2018 elections.
The long-term success of Iraq's military campaign will depend on the emergence of new political movements taking over the reins of government, which is a remote possibility to say the least.
"Al-Qaeda 2.0" may be close to defeat, but for anyone who thinks that this fight is over, "al-Qaeda 3.0" is just around the corner.
*Author of The Struggle for Iraq's Future.
Source: Al Jazeera News