President Donald Trump claimed Wednesday that he "essentially" fired Defense Secretary Jim Mattis, who resigned in protest Dec. 20, for failing to crush the Taliban and end the war in Afghanistan, now in its 18th year.

In remarks at a White House Cabinet meeting, Trump said of Mattis, "What's he done for me? How had he done in Afghanistan? Not too good. I'm not happy with what he's done in Afghanistan, and I shouldn't be happy. He [Mattis] was very happy," according to White House pool reports.

The stunning comments by Trump about the legendary retired four-star Marine general followed the president's equally stunning announcement via Twitter on Dec. 19 that the estimated 2,000 troops in Syria would be withdrawn.

A day after Trump's Syria announcement, Mattis sent out a letter of resignation in which he stressed that U.S. national security interests were best served by working with allies and local partnered forces in Syria and elsewhere.

Mattis said Trump as commander-in-chief deserved a defense secretary who held views "better aligned" with his own and offered to stay until Feb. 28 while the president found a successor.

At the Cabinet meeting, Trump said he "essentially" fired Mattis by ordering him out of the Pentagon by Jan. 1. Trump announced via Twitter that Deputy Defense Secretary Patrick Shanahan, a former Boeing executive, would become acting secretary of defense Jan. 1 and could possibly serve in that post for a lengthy period of time before he settles on a permanent replacement.

In his first message as acting secretary Tuesday, Shanahan said he was looking forward to "working with President Trump to carry out his vision" for promoting the nation's defense.

Trump initially praised Mattis following his sudden resignation, saying in a series of Tweets that Mattis had "served with distinction" for nearly two years as defense secretary and had made "tremendous progress" in reforming the Pentagon and carrying out Trump's policies.

In October, Trump fueled speculation that Mattis was on his way out by going on CBS' "60 Minutes" to say of Mattis that "it could be" that he was about to resign.

"I think he's sort of a Democrat, if you want to know the truth. But General Mattis is a good guy," Trump said. "We get along very well. He may leave. I mean, at some point, everybody leaves. Everybody. People leave. That's Washington."

However, Mattis, in several informal sessions with Pentagon reporters in recent months, had brushed off increasing speculation that he was about to leave.

Trump has often voiced doubts about the contribution to U.S. security from the commitment of troops to Afghanistan and the current cost to taxpayers of about $45 billion annually.

In his August 2017 address to the nation, Trump announced he was reluctantly committing to sending an additional 5,000 troops to Afghanistan in a new "conditions-based" strategy that had no timeline for withdrawal.

He also stated in the address that his initial instinct was to order the withdrawal of all U.S. troops from Afghanistan, but he acted on advice from Mattis and Army Gen. John Nicholson, then the commander of U.S. and NATO forces in Afghanistan, to commit more personnel.

Since Trump announced the Syria withdrawal, reports from The Associated Press and others, citing U.S. defense officials, have stated that he also has ordered plans to cut the estimated 14,000 U.S. troops in Afghanistan by half this year.

In commenting on the reports, both Joint Chiefs Chairman Gen. Joseph Dunford and Army Gen. Scott Miller, who took over in September as commander of U.S. and NATO forces, have said they have thus far received no orders on withdrawals, according to Stars & Stripes.

-- Richard Sisk can be reached at Richard.Sisk@Military.com.