On June 29, 2014 Abu Bakr al-Baghdadi, standing on the pulpit of the al-Nuri mosque in Mosul, declared his caliphate.

On the same day three years later, that mosque was captured by Iraqi military forces. Iraqi prime minister Haider al-Abadi used an electronic pulpit, Twitter, to celebrate the victory over the Islamic State of the Iraq and the Levant (ISIL, also known as ISIS).

While the date of the mosque's capture is redolent with symbolism, the theatrics of the event cannot hide the anxieties and fear of the Iraqis and the international community that Abadi's declaration is premature, as ISIL has not been completely eliminated in Mosul, or worse, might make a coordinated comeback in the city.

The Iraqi government's military victory has now opened up a space for a political solution to reintegrate the city. How the Iraqi state manages this delicate process will ultimately determine ISIL's ability to threaten the nation in the future.

Securing urban centres

After ISIL was expelled from Iraqi towns such as Tikrit, Falluja, and Ramadi over 2015 and 2016, the central government's management of both reconstruction and resettlement of these urban centres has been ad hoc and lethargic, owing to a lack of funds and political will. The same can be said for the districts of Mosul freed from ISIL over the past couple of months. As Mosul reverts back to the central government's control, it must be remembered that it was Baghdad's governance of Mosul that led to the conditions that allowed ISIL to find fertile ground in this city in the first place. Reconstruction and resettlement will be the key factors for the citizens of Mosul in reconciling with the central government.

READ MORE: As ISIL's 'caliphate' crumbles, its ideology remains

This issue is paramount as ISIL fighters are still holding out in Mosul districts and are likely to have sleeper cells in liberated areas of the city. Local cooperation will be needed in the face of these looming threats. Nonetheless, a lot has changed since 2014, when Mosul's inhabitants either actively enabled or passively resigned themselves to ISIL's presence.

Mosul's population has endured physical and emotional deprivation under ISIL rule and there is little chance that they will allow it to re-establish its authority over the city.

Not only was ISIL's rule brutal over the past three years, but its destruction of the al-Nuri mosque and its iconic curved minaret, which gave Mosul its nickname "al-Hadba" (the hunchback), symbolically severed any chance of the group reasserting control over the city. With this act, ISIL tried to deprive the Iraqi government of the symbolic victory of capturing the mosque intact.

It also tried to send a message to Mosul residents. ISIL had destroyed Mosul's pre-Islamic heritage in its museum and sites such as Nimrud before, but by destroying that mosque it signalled that Mosul inhabitants were not "true Muslims". As a BBC reporter documented, when ISIL fighters withdrew from one Mosul neighbourhood, they told the local people, "You did not take care of the caliphate, so you do not deserve it".

Mosul's population has endured physical and emotional deprivation under ISIL's rule and there is little chance that they will allow it to re-establish its authority over the city. However, Mosul's traumatic past under ISIL does not translate into de facto support for the government in Baghdad. The question for Iraq's future remains: how to establish its legitimacy among the alienated Arab Sunnis in this city, in addition to the greater Ninawa, Anbar and Salah al-Din provinces. The pace of reconstruction, resettlement, and political inclusion, on the municipal and national level will ultimately determine the peace.

On the national level the Iraqi government has yet to develop a compelling strategic narrative of how a political process can address the underlying conditions which led to the emergence of ISIL in the first place.

What the Iraqi government needs to do

At this juncture in Iraq's post-2003 political development, it may be useful to see what lessons from other conflict zones can be applied to Mosul and other Iraqi areas formerly held by ISIL.

First, the Iraqi state has to articulate a plan that will guarantee the meaningful inclusion of marginalised groups, which include the Arab Sunnis in Mosul and Ninawa province, as well as its minorities, Christians and Yezidis.

Second, the state has to demonstrate beyond mere rhetoric how it will tackle structural inequalities, including corruption and the abuse of power of state security forces and paramilitary actors, in addition to the justice sector institutions. The potential for corruption among these sectors will only increase as reconstruction aid, both Iraqi and international, pours in.

Third, international aid can be made contingent on trust-building measures that foster social cohesion in Mosul and other formerly ISIL-held territories. Such measures include the establishment of grievance mechanisms that create spaces for dialogue between the communities in Mosul and the security sector. Given that it was the behaviour of the Iraqi security forces that alienated many of Mosul's inhabitants before 2014, community policing programmes between locals of Mosul and security forces would foster social cohesion.

Alas, Iraqi national and regional politics are complicated and involve numerous actors, both foreign and domestic, that will only complicate achieving such an agenda. However, true victory in Mosul will not be measured in capturing a destroyed mosque, but long-term, sustainable strategies that might not be captured in a single tweet.

Ibrahim al-Marashi is an assistant professor at the Department of History, California State University, San Marcos. He is the co-author of Iraq's Armed Forces: An Analytical History.

The views expressed in this article are the author's own and do not necessarily reflect Al Jazeera's editorial policy.