The fast-deteriorating situation was set in motion last week, when Trump ordered U.S. troops in northern Syria to step aside, clearing the way for an attack by Turkey, which regards the Kurds as terrorists. Since 2014, the Kurds have fought alongside the U.S. in defeating the Islamic State in Syria, and Trump’s move was decried at home and abroad as a betrayal of an ally.

Over the past five days, Turkish troops and their allies have pushed their way into northern towns and villages, clashing with the Kurdish fighters over a stretch of 200 kilometers (125 miles). The offensive has displaced at least 130,000 people.

On Sunday, U.S. Defense Secretary Mark Esper said all American troops will withdraw from northern Syria because of the increasing danger of getting caught in the crossfire.

“We have American forces likely caught between two opposing advancing armies, and it’s a very untenable situation,” he said on CBS’ “Face the Nation.” He did not say how many would withdraw or where they would go but that they represent most of the 1,000 U.S. troops in Syria.

The peril to American forces was illustrated on Friday, when a small number of U.S. troops came under Turkish artillery fire at an observation post in the north. No Americans were hurt. Esper said it was unclear whether that was an accident.

Trump, in a tweet, said: “Very smart not to be involved in the intense fighting along the Turkish Border, for a change. Those that mistakenly got us into the Middle East Wars are still pushing to fight. They have no idea what a bad decision they have made.”

Later in the day Sunday, Kurdish officials announced they will work with the Syrian government to fend off the Turkish invasion, deploying side by side along the border. Syrian TV said government troops were moving to the north to confront the Turkish invasion but gave no details.

The Kurdish fighters had few options after the United States abandoned them, and it had been anticipated they would turn to Assad’s government for support.

A return by Assad’s forces to the region where Syrian Kurds have built up autonomy in the north would be a major shift in Syria’s long-running civil war, further cementing Assad’s hold over the ravaged country.

It would also mean that U.S. troops no longer have a presence in an area where Russia and Iranian-backed militias now have a role.