President Trump’s order to withdraw essentially all U.S. forces from northern Syria came after the commander in chief privately agitated for days to bring troops home, according to administration officials — even while the Pentagon was making public assurances that the United States was not abandoning its Kurdish allies in the region.

The officials, granted anonymity to describe internal deliberations, described Trump as “doubling down” and “undeterred,” despite vociferous pushback from congressional Republicans who have been loath to challenge the president apart from a few issues, such as national security.

Behind the scenes, Trump has tried to convince advisers and lawmakers that the United States is not to blame for Turkey’s military offensive, which has targeted Kurdish fighters who have aided the U.S. fight against the Islamic State.

But experts — and many Republicans — say otherwise. And even Trump allies say the president needs to do a better job of selling the troop withdrawal to the public, beyond tweets. 

The escalating crisis in northern Syria has prompted further criticism from foreign policy heavyweights in Trump’s party, who argue that the president’s strategies abroad send a concerning message to allies and endanger regional partners. 

“I’ve always looked at the approach the administration takes as very transactional and very short-term in nature,” former senator Bob Corker (R-Tenn.), who chaired the Senate Foreign Relations Committee, said in a phone interview Sunday. “It’s almost seeking headlines for the very next day, but not really thinking through the longer-term impact on our ­country.”

In a tweet and later in the interview, Corker warned against the decision to withdraw support for Kurdish forces, telling The Post that it was a “blight on our character.” He said, too, that it would only embolden Turkish President Recep Tayyip Erdogan, who has given no indication that he would halt the offensive that began Wednesday despite the threat of sanctions from the U.S. Congress and international condemnation. 

“To pull the rug out and to do so in such a hasty manner, where there’s been no preparation, nothing has been done to limit the damage to them, and as [former defense secretary Jim] Mattis and others have said, this is going to create additional activities, additional opportunities for ISIS . . . it’s bad all the way around,” said Corker, who has remained relatively quiet since he left office in January. 

Such criticisms have been echoed publicly and privately by current Republican elected officials who have been increasingly alarmed by the withdrawal, announced in a late-night White House statement on Oct. 6 and fully fleshed out by Defense Secretary Mark T. Esper on Sunday. 

Trump has closely watched that kind of public criticism in recent days — complaining frequently about comments from Sen. Lindsey O. Graham (R-S.C.) in particular — but has been encouraged to stay the course by other allies who support a withdrawal, such as Sen. Rand Paul (R-Ky.) and Fox News Channel host Tucker Carlson, according to administration officials.

The president, one senior administration official said, was particularly heartened by a segment from another Fox News host, Lou Dobbs, defending him last week.

For his part, Graham appeared to be more aligned with Trump on Sunday evening, saying that he planned to work with Democratic and Republican lawmakers on economic sanctions against Turkey.

“The outrage in Syria about Turkey continues. The ripple effect I was concerned about has happened at a faster pace than I believed. The administration needs to be far more aggressive,” Graham said in an interview.

Graham and Sen. Chris Van Hollen (D-Md.) have drafted legislation that would place sanctions on the U.S. assets of people at the highest levels of the Turkish government, including Erdogan, as well as on any military transactions with Turkey.

The two are circulating their plan among Senate offices. 

Graham and Sen. Christopher A. Coons (D-Del.) have also asked Senate Majority Leader Mitch McConnell (R-Ky.) and Senate Minority Leader Charles E. Schumer (D-N.Y.) to arrange a briefing from the Pentagon and State Department, as well as intelligence officials, on the withdrawal. 

An aide to Schumer deferred to the majority leader’s office, although Schumer has said that he wants Esper; Gen. Mark A. Milley, the chairman of the Joint Chiefs of Staff; and Kenneth F. McKenzie Jr., the head of U.S. Central Command, to appear publicly before senators. A spokesman for McConnell said Sunday that he had no announcements to make. A private briefing could help shape the congressional response, as could a closed-door Senate Armed Services Committee hearing on Syria scheduled for Thursday morning. 

Some Republican donors and officials worried that Trump’s decision would trap them in an untenable situation and have deleterious effects around the world. Furthermore, the significant intraparty rift is coming at a time when Trump particularly needs Republican support as he faces the threat of impeachment. 

“Republican senators are going to increasingly resemble a herd of ostriches with their heads in the sand,” said Dan Eberhart, a prominent Republican donor. “They don’t want to break with Trump while simultaneously wanting to disagree with his policy on allowing Turkey to get away with exterminating the Kurds inside Syria.”

Still, Trump has resisted the repeated urging from some of his closest allies to intervene in the situation and has become more convinced that bringing troops home is both the right decision and a key political promise to fulfill ahead of the 2020 ­election.

That view has been reinforced by the reaction from supporters. At a campaign rally in Minneapolis last week, the crowd chanted “Bring them home!” as Trump noted that U.S. troops had been in Afghanistan — the longest war in American history — for nearly two decades. 

During deliberations in the past, Trump has repeatedly pushed to remove troops from Syria but has usually been dissuaded by top officials, such as John F. Kelly, his former chief of staff.

The usual argument against removing troops, according to former senior administration officials, would be that doing so would cause widespread deaths and chaos and Trump would be blamed for it. 

“Normally, convincing him he would be blamed for death and chaos could keep it from happening at least at that moment,” one former senior administration official said.

But current administration officials say many moderating officials like Kelly are gone, and longtime friends say the move is consistent with Trump’s worldview — and that he has long wanted to do this. 

“When he looks at a conflict, he’ll say, do we have a national interest? What is our national interest?” said Chris Ruddy, a Trump ally. “A secondary thing is the money issue. Why are we spending billions, if not trillions, in places like Afghanistan and the Middle East?”

Corker also suggested that the president’s decision was swayed by a circle of current advisers putting “un-thought-out ideas in the president’s head.” 

“I just have known through my years there that so many people have access to the president,” Corker said, declining to name them. “Typically, you want the people who are giving input to have credentials and have knowledge of the area, but I know that’s not the case necessarily today.” 

Some Trump allies were urging him to do more. Retired Gen. Jack Keane, who regularly speaks with Trump and has been a candidate for positions in the past, said he should quickly enforce a no-fly zone and warn Turkish officials that there would be retaliation. 

Keane said international allies had flooded the State Department with concerns about trusting the United States.

“All is not lost,” he said. But not doing anything, he said, “sends a message about trust and reliability, something the United States has taken some pride in since World War II, that we can be counted on.”