Donald Trump declared victory over Islamic State and ordered a withdrawal of U.S. forces from Syria in a sharp reversal of American policy that appeared to take the Pentagon by surprise.

“We have defeated ISIS in Syria, my only reason for being there during the Trump Presidency,” Trump said Wednesday morning on Twitter, according to Bloomberg.

The U.S. military is working to quickly carry out Trump’s order, according to one official with knowledge of the plan. But it wasn’t clear how soon the approximately 2,000 troops would be coming home and what the president’s decision would mean for vulnerable Kurdish allies that they have supported.

In a White House statement later in the morning, spokeswoman Sarah Huckabee Sanders said America has “started returning United States troops home as we transition to the next phase of this campaign,” although she didn’t comment on the pace of that withdrawal. “The United States and our allies stand ready to re-engage at all levels to defend American interests whenever necessary,” she added.

Read alsoUkraine warns of another disinformation campaign by Russia

A precipitous withdrawal could leave America’s Kurdish allies at the mercy of Turkish troops who have long wanted to pursue forces they view as terrorists.

A U.S. departure also would leave Russia and Iran, allies of President Bashar al-Assad, unchecked as prime influences in Syria.

As recently as last week, administration officials disputed the idea that Islamic State is defeated and suggested U.S. involvement would continue.

But Trump has long pressed the military to withdraw from Syria, saying in April that he would make a decision “very quickly.”

“I want to get out, I want to bring the troops back home, I want to start rebuilding our nation,” Trump said at a news conference at the time. He added that “our primary mission” of fighting the Islamic State terrorist group is “almost completed.”

One of the president’s close allies in Congress, who has at times criticized his foreign policy, sharply attacked the withdrawal decision.

Pulling out U.S. forces now would be a “huge Obama-like mistake,” Republican Senator Lindsey Graham said on Twitter.