Jennifer Cafarella is the director of intelligence planning at the Institute for the Study of War.

The Islamic State is not defeated. No matter how many times President Trump says that the United States has won so that he can justify his shocking decision to withdraw from Syria, it is simply not true. His unexpected order — contradicting what senior administration officials were saying hours before and issued after little consultation with the military or Congress — will accelerate an Islamic State recovery, already underway in Iraq and Syria, and reverse years of American counterterrorism efforts, which could set the stage for another 9/11.

The timing and nature of the U.S. withdrawal is terrible. We are racing for the exits at a moment when our gains against the Islamic State are fragile. U.S.-backed forces in Syria were close to seizing a final pocket of the group’s territory in southeastern Syria after a hard-fought campaign. Those operations were still ongoing at the time of Trump’s announcement, but will surely have to stop if U.S. troops must meet the 30-day withdrawal timeline that Trump conjured, apparently from nowhere. Even seizing these last few villages would not have defeated the group, however.

The Islamic State was a terrorist group and an insurgency before becoming an army and a caliphate. Deprived of its territory and army, it has reverted to its roots. It is waging a capable insurgency behind front lines in both Iraq and Syria against military forces. The cities we seized from the Islamic State in Syria have been destroyed and are largely ungoverned. The population that U.S.-backed forces has ostensibly liberated has nowhere to turn. These conditions are similar to those left behind in Iraq after President Barack Obama’s decision to withdraw U.S. troops. Al-Qaeda in Iraq (the Islamic State’s forerunner) had been beaten back even more thoroughly than the Islamic State has been, yet it was able to regroup and seize large swaths of Iraq and Syria within a few years.

Recent intelligence estimates have warned that the Islamic State remains a significant military threat despite its territorial losses. Senior American defense officials described the group in August as “more capable” than al-Qaeda was in Iraq at its peak in 2006–07. The Pentagon estimated in September that the group retained as many as 30,000 fighters, divided roughly evenly across Iraq and Syria. The Pentagon is quick to emphasize that the Islamic State’s remaining forces are organized into a diffuse network of covert cells rather than conventional units. This isn’t a sign of the group’s defeat. It tells us that it retains enough support within local populations to allow it to embed thousands of fighters within those communities. This should give the president serious pause.

The Islamic State was already reconstituting its remaining pockets of fighters into a capable insurgent force before Trump’s decision. An Islamic State force southwest of the Iraqi city of Kirkuk provides a dangerous warning of what is to come. It is conducting an organized campaign to extort resources from the local population, assassinate local leaders who oppose it and degrade counter forces’ capability through persistent attacks.

The Islamic State is conducting similar efforts across Iraq and Syria to try to regain the freedom of movement necessary to transition back into a sustained counteroffensive. It is regrouping in the Syrian desert, raiding Assad regime positions for supplies and expanding into al-Qaeda-dominated Idlib province to access supply routes across the Turkish border. The group is already using covert cells to attack terrain that U.S.–backed forces liberated, including detonating car bombs in Raqqa. These attacks demonstrate the penetration of the Islamic State’s covert networks and send an important signal to locals: The group is here to stay. The security gap created by an American withdrawal will allow it to accelerate these efforts. The psychological damage caused by the United States' abandonment will make local populations more receptive to it.

Al-Qaeda will benefit perhaps even more than the Islamic State. The group has quietly built influence within the Syrian opposition. Al-Qaeda argues that it is the Syrians’ only true ally against President Bashar al-Assad, and cites seven years of its military operations against him as proof. It seeks to exploit Syrians’ feelings of abandonment by the international community and persuade them to discard their pursuit of democracy in favor of a global religious jihad. With his announcement, Trump has handed al-Qaeda its biggest victory in a generation.

Al-Qaeda’s size in Syria is unclear but is widely cited to be at least 10,000 fighters, including thousands of capable foreign fighters. This force is concentrated in Idlib province but includes covert networks across western Syria. Al-Qaeda and groups operating alongside it have proved capable of penetrating deep into regime-held terrain, conducting numerous bombings this year. They have not yet launched a major offensive, focusing instead on consolidating governance in Idlib. When they do, it will plunge Syria into another round of bloodshed.

There is no viable option to manage the terrorism problem in Syria from a distance or outsource it. Regional actors are counterproductive and will only become more so as the United States retreats. Turkey works with groups linked to al-Qaeda in Syria and will probably now use them to invade and occupy more terrain as U.S. forces leave. Iran pushes sectarianism, fueling jihadist recruitment. Russia’s scorched earth approach was effective at breaking the will of civilians and moderates who lacked outside support, but it will not defeat hardened jihadists. Allowing Russia to try will only accelerate radicalization.

Trump must halt and reverse his decision to withdraw in order to avoid putting us on a path to the next 9/11. There will be no American security from terrorism attacks while the Assad regime and its backers continue to slaughter the Syrian people. Yes, the United States must get out of an endless cycle of wars in the Middle East. But not by losing them.

Read more:

Josh Rogin: Trump undermines his entire national security team on Syria

The Post’s View: This is not the way to leave Syria

David Ignatius: Is Trump handing Putin a victory in Syria?

Max Boot: How can the United States remove Assad? There’s no good way.