President Donald Trump is pulling all 2,000 U.S. troops out of Syria, officials announced Wednesday as the president suddenly declared victory over the Islamic State, contradicting his own experts' assessments and sparking surprise and outrage from his party's lawmakers who called his action rash and dangerous.

The U.S. began airstrikes in Syria in 2014, and ground troops moved in the following year to battle the Islamic State, or ISIS, and train Syrian rebels in a country torn apart by civil war. Trump abruptly declared their mission accomplished in a tweet.

"We have defeated ISIS in Syria, my only reason for being there during the Trump Presidency," he said as Vice President Mike Pence met with top leaders at the Pentagon. U.S. officials said many details of the troop withdrawal had not yet been finalized, but they expect American forces to be out by mid-January.

Later Wednesday, Trump posted a video on Twitter in which he said is "heartbreaking" to have to write letters and make calls to the loved ones of those killed in battle. "Now it's time for our troops to come back home," he said.

A senior administration official, speaking to reporters on condition of anonymity, said Trump made the decision based on his belief that U.S. troops have no role in Syria beyond combatting Islamic State, whose fighters are now believed to hold about 1 percent of the territory they did at the peak of their power.

The president informed Turkish President Recep Tayyip Erdogan of his decision in a telephone call, the official said. Turkey has recently warned that it would launch combat operations across its southern border into northeastern Syria against Kurdish forces who have been allied with the U.S. in the fight against the Islamic State.

Trump's declaration of victory was far from unanimous, and officials said U.S. defense and military leaders were trying to dissuade him from ordering the withdrawal right up until the last minute. His decision immediately triggered demands from Congress — including leading Republicans — for more information and a formal briefing on the matter. Sen. Lindsay Graham of South Carolina, just returned from Afghanistan, said he was meeting with Defense Secretary Jim Mattis late in the day.

Graham, typically a Trump backer, said he was "blindsided" by the report and called the decision "a disaster in the making." He said, "The biggest winners in this are ISIS and Iran."

The decision will fulfill Trump's long-stated goal of bringing troops home from Syria, but military leaders have pushed back for months, arguing that the IS group remains a threat and could regroup in Syria's long-running civil war. U.S. policy has been to keep troops in place until the extremists are eradicated.

The senior administration official said American forces would still work with allies to fight the Islamic State or other extremists in the country but gave no details on what that might entail.

Another official said it still is not clear to defense leaders whether U.S. airstrikes against IS insurgents will continue in Syria after the American troops leave. U.S. military officials worry that American-backed Kurdish troops will be targeted by Turkey and the Syrian government, leaving no ally on the ground to help direct the strikes.

Israeli Prime Minister Benjamin Netanyahu, who remains concerned about Iranian efforts in the area, reacted in noncommittal fashion after talking with Trump by telephone.

"This is, of course, an American decision," he said. No matter what, he said, "we will safeguard the security of Israel and protect ourselves from this arena."

Leading Republican senators reacted with displeasure to the news.

Sen. Marco Rubio of Florida said the withdrawal would be a "grave error" and that Kurdish fighters will stop fighting the Islamic State when they must confront Turkish troops crossing the border into Syria.

"This is a bad idea because it goes against the fight against ISIS and potentially helps ISIS," he said, warning it could trigger a broader conflict in the region.

Just last week, the U.S. special envoy to the anti-ISIS coalition, Brett McGurk, said U.S. troops would remain in Syria even after the Islamic State was driven from its strongholds.

"I think it's fair to say Americans will remain on the ground after the physical defeat of the caliphate, until we have the pieces in place to ensure that that defeat is enduring," McGurk told reporters on Dec. 11. "Nobody is declaring a mission accomplished. Defeating a physical caliphate is one phase of a much longer-term campaign."

And two weeks ago Gen. Joseph Dunford, chairman of the Joint Chiefs of Staff, said the U.S. still has a long way to go in training local Syrian forces to prevent a resurgence of IS and stabilize the country. He said it will take 35,000 to 40,000 local troops in northeastern Syria to maintain security over the long term, but only about 20 percent of that number have been trained.

Trump's national security adviser, John Bolton, said in September that the U.S. would keep a military presence in Syria as long as Iran was active there. "We're not going to leave as long as Iranian troops are outside Iranian borders and that includes Iranian proxies and militias," he said.

James Stavridis, a former Navy admiral who served as top NATO commander, tweeted Wednesday that "Pulling troops out of Syria in an ongoing fight is a big mistake. Like walking away from a forest fire that is still smoldering underfoot. Big winner is Iran, then Russia, then Assad. Wrong move."

The withdrawal decision, however, is likely to be viewed positively by Turkey, and comes following several conversations between Trump and Erdogan over the past several weeks. The two spoke at the G-20 summit in Argentina and in a phone call last Friday.

Erdogan said Monday he had gotten "positive answers" from Trump on the situation in northeast Syria where he has been threatening a new operation against the American-backed Syrian Kurdish fighters.

Just hours before the withdrawal decision became public, the State Department announced late Tuesday that it had approved the sale of a $3.5 billion Patriot missile defense system to Turkey. The Turks had complained that the U.S. was slow walking requests for air defenses, and they had signed a deal with Russia to buy a sophisticated system in a deal that Washington and Ankara's other NATO partners strongly opposed.

Completion of that deal with Russia for the S-400 system would have opened up Turkey to possible U.S. sanctions and driven a major wedge between the allies. It was not immediately clear if there was a connection between the Patriot sale and the decision on U.S. troops.

Although the withdrawal decision doesn't signal an end to the American-led coalition's fight against the Islamic State, it will likely erode U.S. leadership of that 31-nation effort. The administration had been preparing to host a meeting of coalition foreign ministers early next year.

"The bottom line is that the American withdrawal from eastern Syria will create a power vacuum that will lead to a new phase of international conflict in Syria," said Jennifer Cafarella, a Syria expert at the Institute for the Study of War.

She predicted that the Russians, the Iranians, Syrian President Bashar Assad and the Turks will compete for the terrain and resources previously under U.S. control "at the expense of" the Syrian Kurds who have partnered with U.S. forces against IS.

___

Associated Press writers Susannah George and Catherine Lucey contributed to this report.