(Sarah Parnass,Jesse Mesner-Hage/The Washington Post)

Ash Carter, U.S. defense secretary from 2015 to 2017, is director of Harvard’s Belfer Center for Science and International Affairs and an MIT innovation fellow.

After months of tough urban combat, Iraqi Prime Minister Haider al-Abadi declared victory Monday over the Islamic State in its last strategic stronghold in Iraq. Iraqis celebrated in the streets, and Americans should cheer as well.

The liberation of Mosul and the inevitable, approaching liberation of Raqqa in Syria will not be the end of the Islamic State and its evil ideology. But they crush the group’s pretense to having an actual “state” based upon it. As its surviving leaders scurry to the corners of the desert, no longer can they claim to head a winning movement. Their defeat diminishes the inspiration for violent extremists, or simply lost souls on social media, to attack Americans and our friends. This is a necessary step forward in combating terrorism. Americans are safer for it.

The credit for liberating Mosul should go to the brave Iraqi forces who carried out the fight, as well as to the Kurdish peshmerga forces. But credit is also due to the superb execution by U.S. and coalition forces of the military campaign plan to train, equip and enable Iraqi security forces put in motion more than a year ago.

Conducting the campaign in this way was strategically necessary to set the conditions for a truly lasting defeat of the Islamic State. An alternative would have been to use U.S. ground forces from the get-go. But this would have ceded our military advantage to the enemy in the urban terrain of a foreign country, and it might also have induced some who are helping the campaign (or at least sitting on the sidelines) to join the enemy. Finally, it would have left the problem of post-conflict stabilization and governance unresolved. History has shown this task is difficult for outsiders to accomplish.

Importantly, credit goes to my successor, Defense Secretary Jim Mattis, and Chairman of the Joint Chiefs of Staff Joseph Dunford for not only continuing this military campaign but also continuing to seek ways to accelerate it. And then there are the superb military commanders: the U.S. Central Command’s Joe Votel, campaign leaders Sean McFarland and Steve Townsend, and a host of others.

While there’s much to celebrate in the fall of Mosul, we also need to steel ourselves for the road ahead. The defeat of the Islamic State in Mosul and Raqqa is necessary but not sufficient.

At this stage, I am less concerned about the military campaign in Iraq than the political and economic campaigns that must follow. Unless Iraqis are satisfied with what comes next, there will be a slide back to chaos and radicalism. I also believe that a sustained U.S. military presence will be needed in order to improve Iraqi security forces and enable them to keep the peace. Coalition partners are essential: Italy, for example, is superb at training police. Gulf Arab states can make a major contribution to lasting security in their own region by providing critical economic assistance.

Syria will be even more complex. Among the most important decisions that the Trump administration has made was approving the provision of arms and training to Kurdish elements of the Syrian Democratic Forces to lay siege to Raqqa. This was controversial because Turkey opposed such a move, but it is the only viable option for liberating Raqqa. While the final decision did not occur during the Obama administration, I strongly supported backing the SDF, including the Kurds. Now, the Islamic State’s days in Raqqa are numbered. Going forward, however, it will be important that we continue to reassure Turkey, a NATO ally, by holding the SDF to its commitments.

Russia has played no constructive role in these impending U.S.-led victories. President Vladi­mir Putin sent forces into western Syria under the pretense of fighting terrorism and inducing a political transition away from the murderous regime of Bashar al-Assad. Putin did neither. Any broader U.S. cooperation with Russia beyond deconflicting military operations would require Moscow to meet conditions that it has never met. The United States should avoid being enticed by new Putin gambits along the same lines.

Elsewhere, and for some time to come, the fight against extremist terrorism will need to continue. In Afghanistan, for example, I was grateful to President Barack Obama for approving my and Dunford’s recommendations first to delay drawing down, and then to increase, the U.S. forces advising and assisting Afghan forces and the government of President Ashraf Ghani. I strongly support continuing efforts to improve security there. It’s not just that we cannot allow Afghanistan once again to become a base for attacking the United States; there’s also the upside of maintaining a security partnership in a region of strategic importance.

We will need to maintain our resolve to achieve a lasting defeat of the Islamic State. But for now let’s thank our troops and their commanders. Let’s thank the Iraqis and the Syrian forces taking on the terrorist group. The world should note that no country but the United States could have led such a coalition to victory. That’s a fitting rejoinder to anyone who believes our internal disarray and partisan politics are reason to doubt U.S. staying power.