The relationship between President Trump and Secretary of Defense Jim Mattis, who appeared at a White House reception on Oct. 25, is showing signs of strain. (Jabin Botsford/The Washington Post)

President Trump’s decision to abruptly withdraw troops from Syria is a clear rebuke to Defense Secretary Jim Mattis, the last remaining member of a retinue of military men Trump once fondly called “my generals.”

Mattis had argued that the counterterrorism mission in Syria is not over and that the small U.S. presence in Syria should remain, said current and former U.S. officials who spoke on the condition of anonymity to share internal policy discussions.

The Pentagon chief also had tried to explain to Trump that there would be more chaos in the region and future problems for the United States if the troops leave, they said.

On Wednesday, it became clear Trump was brushing aside his defense secretary’s advice.

Once considered among the most influential advisers to a president with no prior government or military experience, Mattis has been repeatedly overruled by Trump in recent months and left out of key discussions as the president pursues his own national security path.

The retired four-star Marine Corps general Trump likes to call by his detested nickname, “Mad Dog,” is now at a low point in his influence with Trump and potentially also a short-timer, current and former U.S. officials said.

Mattis is also frustrated that Trump vetoed his choice to become the next chairman of the Joint Chiefs of Staff, the nation’s highest-ranking miliary officer. Trump announced this month that he has chosen Gen. Mark A. Milley, the Army’s chief of staff, to replace the current chairman, Gen. Joseph F. Dunford Jr., who is due to step down next fall. Mattis had recommended the Air Force chief of staff, Gen. David L. Goldfein, people familiar with the discussions said.

Trump also sidestepped Mattis’s concern about deploying U.S. forces to the U.S.-Mexico border this fall with only a vague mandate for border security. Mattis has told Pentagon leaders that he is following orders and they must do the same, U.S. officials said.

The 68-year-old retired general was second only to Trump in issuing blunt military threats to North Korea before the president’s abrupt decision in March to seek rapprochement through one-on-one diplomacy with North Korean leader Kim Jong Un. Mattis is said to be among the strongest skeptics about the pledge of denuclearization that Trump claims he received from Kim at a summit in June.

In the beginning of his presidency, Trump often pointed to the military men he brought into his administration as evidence of his seriousness about taking a get-tough approach on national security.

But all those retired and current military officers are now gone (former national security advisers Michael Flynn and H.R. McMaster), on the way out (chief of staff John F. Kelly) or, in the case of Mattis, pushed to the sidelines.

“I see my generals — those generals are going to keep us so safe,” Trump said during a luncheon shortly after he was sworn in as president on Jan. 20, 2017. “They’re going to have a lot of problems, the other side.”

He said the group of military men he had assembled were out of “central casting,” and he singled out Mattis.

“If I’m doing a movie, I pick you, General, General Mattis,” Trump told the audience.

In the beginning of the administration, Mattis maintained his influence with Trump even as he repeatedly argued against some of the president’s iconoclastic impulses — trying to explain with maps and charts how his decisions could hurt American interests, officials who have watched those interactions said.

Mattis often wove in discussion of international trade and U.S. foreign aid, knowing that those subjects are likely to hold the president’s interest, those people said.

The relationship between the two men has shown signs of strain in recent months, and Trump continues to weigh whether he should keep Mattis in the role and tells advisers in the Oval Office that he doesn’t agree with his defense secretary on much, according to current and former administration officials.

He rarely sees Mattis these days and does not speak with him as often as he did earlier in the administration.

Mattis, for his part, has told colleagues that he wants to stay.

David Lapan, a former top military spokesman and aide to Kelly when Kelly was Trump’s first Homeland Security chief, said Trump has taken Mattis and the Pentagon by surprise several times. He cited the ban on transgender troops, Trump’s now-canceled plan for a pull-out-the-stops military parade and the order to send troops to the southwest border.

“This is a whole different level than some of those things,” Lapan said of the Syria decision, which involves deployment of U.S. forces to a war zone.

Mattis will probably seek ways to manage the troop departure rather than make an issue out of opposing it, Lapan said.

“If it’s a lawful order, and presumably this one would be, and you don’t agree with it, you either carry it out or leave,” Lapan said. Mattis would probably approach the matter by saying, “ ‘Is there room for this to be changed in some way?’ ” Lapan said.

Trump sees the Syria decision as a campaign promise and often complains that if it were up to his military advisers, he would never bring troops home from anywhere, White House aides said.

Kelly — also an original member of the “my generals” club — had also argued in favor of keeping the more than 2,000 U.S. forces in Syria. He, along with Mattis and top congressional Republicans, argued that force is an important hedge against terrorism and against Iranian and Russian influence.

Trump made clear on Wednesday that he was no longer heeding their advice, tweeting: “We have defeated ISIS in Syria, my only reason for being there during the Trump presidency.”

Later in the day he added: “After historic victories against ISIS, it’s time to bring our great young people home!”

White House press secretary Sarah Sanders later said that the mission is complete because Islamic State’s “territorial caliphate” had been destroyed. U.S. officials assess that while the Islamic State, also known as ISIS, has lost almost all its physical foothold in Syria, some fighters remain in the country.

Pentagon spokeswoman Dana W. White said that “the Coalition has liberated the ISIS-held territory, but the campaign against ISIS is not over.

“We have started the process of returning U.S. troops home from Syria as we transition to the next phase of the campaign,” she said. “We will continue working with our partners and allies to defeat ISIS wherever it operates.”

Mattis had lots of company in arguing that U.S. troops need to remain in Syria, including from the administration’s special envoy for the defeat of the Islamic State, Brett McGurk, who told reporters last week that U.S. forces would remain in place to secure their military gains.

“It would be reckless if we were just to say, ‘Well, the physical caliphate is defeated, so we can just leave now,’” McGurk said Dec. 11. “I think anyone who’s looked at a conflict like this would agree with that.”

Mattis said in September that while the military mission in Syria is focused on the defeat of the Islamic State, he cited destabilizing Iranian and Russian influences in saying that U.S. forces wouldn’t pull out abruptly.

Dunford said earlier this month that the Pentagon still had “a long way to go” to train local counterterrorism forces in Syria.

Both Secretary of State Mike Pompeo and national security adviser John Bolton have recently said the goal in Syria is broader than simply countering the Islamic State.

A U.S. official who agreed to brief reporters on the condition of anonymity Wednesday would not provide details of the internal policy disagreement but said Trump has been consistent in wanting to pull U.S. forces out.

“It was the president’s decision to make, and he made it,” the official said.

The decision, first reported by the Wall Street Journal and Reuters, was apparently made Tuesday. It was not clear whether Mattis or Pompeo knew of Trump’s decision to make his announcement Wednesday morning. Throughout both Cabinet departments, officials appeared caught unaware when the president’s tweet appeared.

Republican lawmakers were stunned and angry, with several demanding answers from Vice President Pence at a Republican lunch on Wednesday about why they were kept in the dark.

“I don’t know what it is. I haven’t been briefed. I am completely blindsided, and I think there will be a lot of bipartisan concern,” Sen. Lindsey O. Graham (S.C.) said in an interview.

“ISIS has been dealt a severe blow but are not defeated. If there has been a decision to withdraw our forces in Syria, the likelihood of their return goes up dramatically,” while Iran, Russia and Syrian President Bashar al-Assad benefit from the U.S. void, Graham said.

Senators told Pence that “we did not appreciate reading about this decision in the paper,” Graham added.

Missy Ryan and Seung Min Kim contributed to this report.