Defense Secretary James Mattis will step down at the end of February, he announced in a two-page resignation letter that cited his differences with President Donald Trump.

“My views on treating allies with respect and also being clear-eyed about both malign actors and strategic competitors are strongly held,” Mattis wrote in the Dec. 20 letter. “Similarly, I believe we must be resolute and unambiguous in our approach to those countries whose strategic interests are increasingly in tension with ours.”

He concluded by saying the president should have a defense secretary whose views better aligned with his.

President Trump tweeted his acceptance of the letter at 5:21 p.m. Washington time, capping off months of speculation about the fate of the man the president once lovingly referred to as one of “my generals.” The president struck a conciliatory note in his tweet, saying that Mattis will retire “with distinction.”

“During Jim’s tenure, tremendous progress has been made, especially with respect to the purchase of new fighting equipment,” he wrote. “General Mattis was a great help to me in getting allies and other countries to pay their share of military obligations.”

The shock announcement came in the wake of a fierce internal dispute between the White House and the Pentagon over the president’s decision to abruptly withdraw U.S. forces from Syria. Mattis had reportedly advocated against the president’s decision, which ignited an inferno of bipartisan criticism in Washington, much of which was centered on the fact that Trump had overridden his own senior defense advisors.

But Mattis’ influence on the president has been on the wane for months, during which Trump has made a series of sweeping national security decisions that have put him at odds with his defense secretary. When Trump first took office, Mattis famously was able to convince him that torturing terror suspects was ineffective; by this fall, news reports were suggesting that the two speak only infrequently. In an October interview with “60 Minutes,” Trump called Mattis “sort of a Democrat.”

Abroad, Mattis often took on the role of reassuring allies nervous about the unpredictable American president, emphasizing U.S. commitment to the international order safeguarded by NATO even as the president lambasted allied nations over their spending commitments and advanced his signature brand of “America First” foreign policy. Most recently, Mattis reportedly advocated against the Syria withdrawal over concerns that the U.S. would be abandoning allied Kurdish fighters backed by the U.S. in the fight against ISIS.

In his two-page resignation letter, Mattis said that he was stepping down because of the gulf between his views on the value of alliances and partnerships, and those of president.

“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,” Mattis wrote. “My views on treating allies with respect and also being clear-eyed about both malign actors and strategic competitors are strongly held and informed by over four decades of immersion in thee issues. We must do everything possible to advance an international order that is most conducive to our security, prosperity and values, and we are strengthened in this effort by the solidarity of our alliances.

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

A new Defense Secretary will be named “shortly,” Trump said. But Mattis’s resignation is almost certain to throw gasoline on the blaze on Capitol Hill, already roiling over the Syria decision. Mattis, a retired Marine general, enjoyed almost universal respect from lawmakers from both parties. His departure is likely to further unnerve lawmakers already jumpy over the White House’s seemingly erratic policymaking.

“This is scary,” tweeted Sen. Mark Warner, Va., the top Democrat on the Senate Intelligence Committee. “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.”

The decision to withdraw from Syria appeared to have been a unilateral decision by the president, without the usual rigorous interagency review process that would typically accompany such a significant strategic decision. The Pentagon has provided few details about the timing of the withdrawal.

The announcement of Mattis’ resignation also coincided with a report from The Wall Street Journal that Trump is “actively considering plans for a significant drawdown of American troops in Afghanistan that could begin in as soon as several weeks,” another eventuality that Pentagon brass have feared could be in the offing. Trump, who campaigned on a fierce opposition to American interventionism abroad, has publicly expressed ambivalence about the mission there; Pentagon officials say the American presence there is critical to prevent attacks on the homeland.

Although Republicans will have a wider majority in the Senate in 2018, the confirmation fight over Mattis’s replacement is poised to be bloody—few in Washington enjoy a reputation considered as unimpeachable as his.

The tenor of Mattis’ letter immediately set off a firestorm of speculation about whether Mattis or Trump initiated the departure.

“For the sake of our national security I hope his decision to resign was motivated solely by a desire to enjoy a well deserved retirement,” tweeted Sen. Marco Rubio, R-Fla.

Related podcast: