President Donald Trump’s sudden move to yank U.S. troops out of Syria undermined at a stroke several foreign policy goals he has championed. The president promised to finish the job of destroying the Islamic State, but the withdrawal will leave thousands of its fighters still in place. He vowed to roll back Iran’s aggression across the Middle East, but his decision will allow its forces to entrench in the country that is the keystone of Tehran’s ambitions. He promised to protect Israel, but that nation will now be left to face alone the buildup by Iran and its proxies along its northern border.

The president’s top national security advisers had carefully developed and articulated a strategy of maintaining a U.S. presence in Syria until the Islamic State was beyond revival and Iran withdrew its forces — a plan they were defending up until this week. Trump has again demonstrated, to them and to the world, that no U.S. policy or foreign commitment is immune from his whims.

Trump claimed the Islamic State had been defeated, but that is not the view of the Defense and State departments. Thousands of jihadist fighters are still in Syria and control splotches of territory in the Euphrates Valley. A U.S. withdrawal will give the extremists an opportunity to reconstitute, as they did in Iraq after the premature U.S. withdrawal ordered by President Barack Obama.

Until Wednesday, a prime talking point of senior national security officials was that “if we’ve learned one thing over the years, (the) enduring defeat of a group like this means you can’t just defeat their physical space and then leave,” as the State Department’s special envoy for the global campaign against the Islamic State, Brett McGurk, put it last week. Defense Secretary Jim Mattis said it another way in September: “Getting rid of the caliphate doesn’t mean you then blindly say, `OK, we got rid of it,’ march out, and then wonder why the caliphate comes back.”

Trump has justified some of his most controversial decisions, including his continued support for Saudi Arabia’s Crown Prince Mohammed bin Salman, as needed to contain Iran’s threat to the United States and its allies. But the Syrian withdrawal hands Tehran and its ally Russia a windfall. Iran has deployed thousands of fighters and allied militiamen to Syria and aspires to create a corridor to Lebanon and the Mediterranean, as well as a new front against Israel along the Golan Heights.