U.S. soldiers surveil an area in Manbij, Syria, during a combined joint patrol on Nov. 1. (U.S. Army/Reuters)

PRESIDENT 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. Mr. Trump has again demonstrated, to them and to the world, that no U.S. policy or foreign commitment is immune to his whims.

Mr. 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 following 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, ‘Okay, we got rid of it,’ march out, and then wonder why the caliphate comes back.”

Mr. 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 Syria 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. In reaction to that threat, Mr. Trump’s national security adviser, John Bolton, announced Sept. 24 that “We’re not going to leave [Syria] as long as Iranian troops are outside Iranian borders, and that includes Iranian proxies and militias.”

U.S. ambitions in Syria have never been backed by adequate resources, and a case could be made that neither Congress nor the American public were prepared to support the mission suggested by Mr. Bolton. But Mr. Trump’s decision appears to have been precipitated by the bellicose rhetoric of Turkey’s Recep Tayyip Erdogan, who last week threatened — not for the first time — a military operation against Syrian Kurds, even though U.S. troops are positioned around them. The autocratic Turkish ruler appears to have extracted favors from Mr. Trump in recent days, including the sale of U.S. Patriot missiles and a promise to reexamine the possible extradition of his rival, Fethullah Gulen, from Pennsylvania. If Mr. Trump received anything in return, he hasn’t disclosed it.

The Syrian Kurdish forces, which have fought alongside the United States and played a crucial role in liberating most of eastern Syria from the jihadists, will be perhaps the foremost victims of Mr. Trump’s decision. Betrayed by Washington, they will now be subject to a military offensive by Turkey. The stab in the back will send an unforgettable message to all who are asked to cooperate with the United States in the fight against terrorism: Washington is an unreliable and dangerous partner.