A U.S. soldier waves from an armored vehicle in Manbij town, north Syria, on April 4, 2018. (Hussein Malla/AP)

EVER SINCE President Trump abruptly announced the withdrawal of U.S. forces from Syria in December, his top aides, military commanders, congressional leaders and U.S. allies have scrambled to reverse or modify a decision that portended disastrous consequences. It appears they finally made headway. Administration officials said Friday that some 400 U.S. troops will remain in the country, compared with about 2,000 now, split between a northern area along the Turkish border and a southern base near Jordan.

It’s not clear whether that modest deployment will be enough to protect U.S. interests, which include preventing conflict between U.S.-allied forces in Syria and Turkey, ensuring that Islamic State militants in the region do not regroup, and avoiding a strategic windfall for Iran and Russia. But it is a positive step that, with luck, will temper a major strategic blunder by Mr. Trump.

The president announced the abandonment of Syria abruptly and without consulting advisers or allies. He never offered a cogent explanation, merely repeating empty slogans about bringing U.S. troops home from “endless wars” and refusing to become “the Policeman of the Middle East.” Until late this week, he appeared deaf to the senior military officials, Republican senators and European leaders who warned he was badly misreading the situation in Syria and the stakes for the United States.

In reality, the U.S. mission there, unlike those in Iraq and Afghanistan, has been a nearly unqualified success. Having learned the lessons of those earlier wars, American commanders established a light footprint in northeastern Syria and forged an alliance with Kurdish-led local forces. U.S. personnel armed and trained those fighters, and backed them with airpower as they liberated territory from the Islamic State. This campaign incurred seven U.S. combat deaths in four years and left the allies in control of a large and strategic swath of territory. For the first time, Washington had meaningful leverage in bargaining over Syria’s future.

Having dissuaded Mr. Trump, for now, against throwing those gains away, U.S. commanders and diplomats can now return to pursuing the goals they had previously set, which include ensuring that the thousands of remaining extremist fighters in Syria do not regroup and seeking an acceptable settlement of the Syrian civil war. That will necessarily involve curtailing Iran’s presence in the country, including its attempt to entrench fighters and advanced missiles threatening Israel.

The first step will be striking a deal with Turkey to create a buffer zone between it and the U.S.-allied Syrian Kurds — a delicate enterprise that will require Mr. Trump to stand up to Turkish President Recep Tayyip Erdogan rather than capitulate to his demands. U.S. officials will also try to persuade Britain and France to continue their own deployments of counterterrorism forces in northern Syria; the Europeans had previously said they would not remain in the event of a U.S. withdrawal.

All of this is made more difficult by Mr. Trump’s steadily deteriorating relationships with key European allies and his inclination to accommodate autocrats such as Mr. Erdogan and Russia’s Vladi­mir Putin. For now, however, the president deserves credit for listening to those who warned him against the Middle Eastern pitfall he was blundering into.