The liberation of Mosul from the depravity of Islamic State of Iraq and Syria terrorists is a rare moment of good news from a region reeling from enduring, brutal warfare.

Credit is due to Iraqi security forces, which previously performed so poorly when the initial invasion by ISIS quickly captured broad swaths of the country.

The monthslong counterattack by refortified forces, however, was a strategic success. A multisectarian military contingent, aided by expert and intrepid U.S. forces, made Mosul just the latest ISIS stronghold to fall as the so-called caliphate continues to lose territory and, by extension, legitimacy in the eyes of potential recruits.

Victory in Mosul is “a very significant development, a major defeat for ISIS that will end them as a ‘caliphate,’ ” James Jeffrey, who was U.S. ambassador to Iraq from 2010-2012, told an editorial writer.

Now the U.S. must stay fully engaged in the region in order to win the peace, added Jeffrey, who is now a senior fellow at the Washington Institute for Near East Policy.

Mosul is structurally and psychologically devastated after years of ISIS barbarity and subsequent allied bombardment that has contributed to the city’s enormous destruction. On a humanitarian level, it’s necessary to address this catastrophe by rallying donors to help Iraq rebuild its second-biggest city. It’s also key on a political level, lest sectarianism recreate conditions that resulted in an environment in which ISIS or another terrorist threat could again appeal to grievances and take root. And it’s imperative to end the reported extrajudicial killings of suspected ISIS members by Iraqi forces.

This sectarianism was accelerated by the heavy hand of former Iraqi President Nouri al-Maliki. It was also exacerbated by Iran, which has dramatically increased its influence in Iraq since the 2003 U.S. invasion.

Al-Maliki’s replacement, President Haider al-Abadi, has surpassed nearly every expectation in his ability to rally Iraqis to fight ISIS and for his more nuanced approach to the delicate sectarian balance between the majority Shiites and minority Sunnis, as well as Kurds, whose essential role in Mosul will only increase calls for an independent Kurdish state.

The fight against ISIS is certainly not over in Iraq, where the group still controls some territory. Nor is it over in Syria, where the caliphate’s “capital” of Raqqa is still in ISIS hands. The U.S. should continue to aid indigenous forces as they press on with their assault, a process begun under former President Barack Obama that has generally continued under President Donald Trump.

Domestic distractions and a desire to downshift involvement in the Mideast may tempt the Trump administration to disengage from Iraq. Just as the drawdown under the Obama administration was a mistake, so too would ceding more influence to Iran. While the future of Iraq should be up to Iraqis, the U.S. must continue to play a vital role.