President Donald Trump said Thursday that Defense Secretary Jim Mattis will leave the administration in early 2019, but the onetime Marine Corps general is doing it on his own terms – listing the ways he's incompatible with his commander-in-chief.

Chief among them is that Mattis believes Trump hasn't tended the diplomatic garden of international alliances, leaving the United States unable to defend its interests overseas.

And the timing of his announcement was unmistakably linked to the president's announcement Thursday of a troop pullout from Syria that the two men disagreed about.

'Because you have the right to a Secretary of Defense whose views are better aligned with yours on these and other subjects,' Mattis wrote after his litany, 'I believe it is right for me to step down from my position.'

Trump treated the departure like any other in Washington's revolving doors.

'General Jim Mattis will be retiring, with distinction, at the end of February, after having served my Administration as Secretary of Defense for the past two years,' he tweeted.

'During Jim’s tenure, tremendous progress has been made, especially with respect to the purchase of new fighting equipment. General Mattis was a great help to me in getting allies and other countries to pay their share of military obligations. A new Secretary of Defense will be named shortly. I greatly thank Jim for his service!'

Mattis' message Thursday was far less rosy – a rhetorical flamethrower with a touch of khaki.

Farewell to arms? Defense Secretary Jim 'Mad Dog' Mattis, a former U.S. Marine Corps general, will step down from his post atop the Pentagon in February

President Donald Trump reportedly overruled Mattis' objection this week in deciding to withdraw American troops from Syria

In his resignation letter, Mattis spelled out his strategic views and said Trump should find a defense secretary he agrees with more

'One core belief I have always held is that our strength as a nation is inextricably linked to the strength of our unique and comprehensive system of alliances and partnerships,' he wrote.

'While the US remains the indispensable nation in the free world, we cannot protect our interests or serve that role effectively without maintaining strong alliances and showing respect to those allies.'

Mattis also declared that America 'must be resolute and unambiguous in our approach to those countries whose strategic interests are increasingly in tension with ours.'

In clear references to Russia and China, he wrote about four decades of 'immersion' in global affairs, leading him to believe in 'treating allies with respect and also being clear-eyed about both malign actors and strategic competitors.'

At the White House, Press Secretary Sarah Huckabee Sanders told a crush of reporters that Mattis made the decision about the timing of his announcement.

'He and the president have a good relationship, but sometimes they disagree,' she acknowledged, responding to a question about the Syria troop pullout's role in the defense secretary's departure.

'The president always listens to members of his national security team, but at the end of the day, it's the president's decision to make,' she said. 'He was the one to be elected president, to be the commander in chief, and while he takes all of their opinions, and all of their advice into consideration, at the end of the day it's his decision to make.'

White House Press Secretary Sarah Huckabee Sanders didn't deny on Thursday evening that Mattis timed his departure to show displeasure with Trump's decision to withdraw America's troops from Syria over his objection

The president stunned Washington with his announcement, making it on Twitter instead of in an official statement

Trump made waves Wednesday at the Pentagon by announcing his withdrawal of America's mid-size military contingent stationed in Syria.

The decision, reached Tuesday in a small group meeting at the White House, didn't include consultation with Gen. Joseph F. Dunford Jr., the chairman of the Joint Chiefs of Staff.

Mattis and Secretary of State Mike Pompeo were in the room. Both objected.

Trump declared this week that his administration has won the war against the ISIS terror army, even though the Pentagon has said the group still has 30,000 soldiers in Iraq and Syria.

Some administration officials are bracing for a possible pullout from Afghanistan next. The U.S. has 14,000 troops stationed there.

According to CNN, no decision has been made but officials are worried Trump might act soon to pull out of a conflict he has long claimed America should never have entered.

The president asked back in 2011, years before he began to flaunt his political ambitions: 'When will we stop wasting our money on rebuilding Afghanistan? We must rebuild our country first.'

Reactions to Mattis' announcement fell along partisan lines on Thursday.

House Minority Leader Nancy Pelosi, who will become speaker in January, said during a press conference at the Capitol that she was 'shaken by the resignation of General Mattis' and called it 'a very sad day for our country.'

Pelosi encouraged reporters to read the resignation letter, and to pray for the United States.

'You have leaders, great leaders who have left the administration in dismay and the rest of them have left in disgrace. And that's what this administration has been about,' she claimed.

Most Republicans thanked the defense secretary for more than 40 years of public service. Many Democrats lamented that one of the Trump administration's few 'adults in the room' would be leaving.

Illinois Democratic Sen. Dick Durbin said on Twitter: 'America has lost more than an exceptional Secretary of Defense. We have lost the adult in the room when the President goes off on a tweet-filled, uninformed rant about our national security.'

California Democratic Rep. Adam Schiff will chair the House Intelligence Committee next year; he blasted Trump for ignoring Mattis' advice

Illinois Democratic Sen. Dick Durbin said the Trump administration has 'lost the adult in the room'

Florida Sen. Marco Rubio was among very few Republicans to offer anything but wistful thanks; he tweeted that the Mattis resignation letter points to serious flaws in America's strategic thinking overseas

Tennessee Rep. Jim Cooper appeared to be tweeting from the same talking points. 'I worry the White House meeting rooms will soon be vacant of adults,' he wrote.

California Democratic Rep. Jimmy Gomez chimed in: 'The adults have officially left the building.'

Fellow Californian Adam Schiff, who will chair the House Intelligence Committee in 2019 and 2020, took his criticism a step further.

'Old Marines never die, but they do resign after the President ignores their advice, betrays our allies, rewards our enemies, and puts the nation’s security at risk. Turn out the lights when Mattis leaves; we will not see his like again while Trump remains in office,' Schiff tweeted.

Outgoing House Speaker Paul Ryan, a retiring Wisconsin Republican, issued a more traditional statement, saying Mattis has made the nation 'a safer America at home, and a more commanding force abroad. His patriotism and grit are matched only by his humility and graciousness.'

On GOP dissenter, Florida Sen. Marco Rubio, tweeted that Thursday's resignation letter 'makes it abundantly clear that we are headed towards a series of grave policy errors which will endanger our nation,damage our alliances & empower our adversaries.'

The top Democrat on the Senate Intelligence Committee called Mattis' planned departure 'scary,' saying the retired general 'has been an island of stability' amid Trump's chaos

Trump has speculated before about how long Mattis might stay in his Cabinet.

Asked in October during a '60 Minutes' interview whether his Defense Department chief might be on his way out, he responded: 'Well, I don't know. He hasn't told me that.'

'I have a very good relationship with him. It could be that he is. I think he's sort of a Democrat, if you want to know the truth,' he said.

'But General Mattis is a good guy. We get along very well. He may leave. I mean, at some point, everybody leaves. Everybody. People leave. That's Washington.'

Virginia Democratic Sen. Mark Warner tweeted in horror on Thursday: 'This is scary.'

'Secretary Mattis has been an island of stability amidst the chaos of the Trump administration. As we’ve seen with the President’s haphazard approach to Syria, our national defense is too important to be subjected to the President’s erratic whims.'

Warner is vice chairman of the Senate Intelligence Committee.

Mattis isn't the only senior official on the way out. White House Chief of Staff John Kelly will depart in a matter of weeks, and Interior Secretary Ryan Zinke is also on a glide path to the private sector.

The president drew cheers at political rallies during his late 2016 transition period when he announced that Mattis would run the Pentagon.

Trump was fond of calling him 'Mad Dog,' a nickname Marine lore described as a loving tribute bestowed by the men he led.

In fact, his men in the field had a different moniker for him when he was a Marine colonel. They called him CHAOS, short for 'Colonel Has An Outstanding Suggestion'–a hat tip to Mattis' reputation as a thinking man's soldier.