Mattis, seen as a stabilising force in the White House, abruptly announced his resignation on Thursday just a few hours after it is was reported Trump was also considering significantly reducing troop numbers in Afghanistan.
In his resignation letter published by the Pentagon, he emphasised the importance of standing up for US allies in an implicit criticism of the president’s decisions.
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.
“Because you have a right to 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.”
Trump, announcing Mattis’ departure on Twitter, said he would nominate a successor soon.
“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 said.
The US president contradicted his own experts’ assessments and sparked surprise and outrage from members of his party, who called his action rash and dangerous.
Mattis joins a long list of former Trump administration senior figures who have either quit or been removed – some unceremoniously like Secretary of State Rex Tillerson, who Trump fired via Twitter in March.
Trump’s White House has had the highest turnover of senior-level staff of the past five presidents, according to the Brookings Institution think tank, Reuters reports.
Speculation that Mattis might not last long in his post grew in October when Republican Trump said in a CBS interview that the general was “sort of a Democrat” and might be leaving.
Mattis, along with other national security aides, was said to have opposed Trump’s decision to remove US troops from Syria. Many US lawmakers have expressed concern about the decision and asked Trump to reconsider.