After almost five months of fighting the battle for the Isis stronghold of Mosul seems to finally be coming to an end. Just as the capture of Iraq's third largest city in 2014 put the jihadi group on the international map – so Baghdad is hoping its defeat in Mosul will banish it from Iraq once and for all.

But the challenges ahead could be bigger for Iraq than taking back Mosul, and Baghdad cannot be left to face them alone. The fall of the city will be a resounding victory over a group that has pushed cruelty to unbearable limits, but as politicians in Washington, Tehran, Ankara clamour to claim the victory as their own, Baghdad faces a tremendous task: rebuilding the country.

US President Donald Trump may well be tempted to claim victory over Isis when Mosul falls but he should be wary – Iraq is where the "mission accomplished" speeches go to die. Not so long ago, Iraqis defeated another vicious jihadi group – al-Qaeda in Iraq – yet the devastation it left behind spurned an even more brutal insurgency that has killed innocents in Iraq as well as in Europe and America.

Three years of fighting the Isis has left deep, physical and emotional scars in a country that has struggled to find its way ever since US troops invaded in 2003. Fallujah and Ramadi, which were subject to prolonged and bloody offensives, have yet to return to normal. Isis is still able to operate there and instil fear in the heart of those courageous enough to go back.

How Iraq treats and relocates those displaced by the fighting will play a critical role in the future of the country and its ability to defeat jihadism – once it has defeated the jihadis. The longer internally displaced people (IDPs) will remain in camps, the more radicalisation will grow. The mere presence of IDPs risks fuelling sectarian tensions by shifting Iraq's fragile religious and ethnic balance.

Making sure those displaced by the conflict can return to their homes – and do so without being afraid of being blown to pieces by a suicide bomber – will most certainly require that the mandate of the anti-Isis coalition be extended. Rebuilding Iraq will require a greater number of foreign advisers to continue training both the army and, more importantly, the Iraqi police, who will play a critical role in the future of Iraq as Isis shifts from an almost-conventional force into a criminal organisation.

As cities are rebuilt and secured, Baghdad will also have to make sure those returning have a future in areas that have thus far been ignored by economic reforms, including the rural areas where Isis prospered. Investing in rooting out jihadism is a tremendous task, made even harder by the fact that it doesn't mobilise as much as fighting jihadists, and may even be more costly.

With the current state of its economy, Iraq needs its own Marshall Plan, which focuses on the areas from which Isis came. It may seem obvious, but while dozens of nations have committed to fighting Isis, they may be more unlikely to answer the phone when asked for a significant sums of money.

How that money is spent will also be critical. After WW2 the US spent tremendous amounts to rebuild Germany, having learned from the previous world war and its cause. Iraq's partners should make sure that they do the same, while also ensuring that funds don't end up being misused.

Shia and Sunnis don't need to be protected by Iran or Turkey, but by Baghdad: as Iraqi citizens.

This is easier said than done, in light of both the level of corruption in such an unstable country and the mere fact that investing in areas from where this instability came from may seem unfair to the rest of the population. Rooting out radicalism will take "big money" but it will also take big reforms and an effort to make sure Baghdad remains accountable to Iraqis rather than its foreign backers.

The conflict in Iraq has attracted many "partners", who, under the pretext of fighting the group, have been pushing their own agendas and will do so even more once Mosul fall. The rivalry between Turkey and Iran will likely continue to affect Iraq, as Erdogan postures himself as the "defender of the Sunnis" while Iran continues to build its influence through Shiite proxy.

This sectarian narrative fits exactly in Isis's plans and should be pushed back. Shia and Sunnis don't need to be protected by either Iran or Turkey, but by Baghdad, as Iraqi citizens. In that sense, the Marshall plan that will be required should be conditioned by a series of milestones in terms of governmental, military and economic reforms, while preserving Iraq's independence.

The balance between assistance and infringement in domestic politics will be hard to find, but while the fight against radicalism in Iraq will most likely disappear from news segments, it must not be pushed off the political agenda. For, should it be the case, we might find ourselves fighting a nastier version of Isis in just a few years.

Michael Horowitz is director of intelligence at Prime Source, a Middle-East-based geopolitical consultancy producing updates and analysis on the Syrian and Iraqi conflicts.