Trump says he’s replacing Mattis with deputy defence secretary Patrick Shanahan in an acting capacity on January 1.

US President Donald Trump on Sunday said he was replacing Defense Secretary James Mattis on January 1 with deputy defence secretary Patrick Shanahan in an acting capacity after Mattis resigned over policy differences and offered to stay in his post for two more months.

Trump announced Shanahan’s appointment in a tweet, calling the former Boeing Co executive “very talented” and said that he had a “long list of accomplishments”.

Lieutenant Colonel Joseph Buccino, a spokesman for Shanahan, said the former Boeing executive will accept the appointment as acting secretary.

“Deputy Secretary will continue to serve as directed by the president, and the Department of Defense will remain focused on the defense of the nation,” Buccino said on Sunday.

Mattis resigned on Thursday, a day after Trump overruled his advice against pulling US troops out of Syria and reportedly pressed forward on discussions to withdraw forces from Afghanistan.

Mattis told Trump in his resignation letter that he was leaving because “you have a right to have a Secretary of Defense whose views are better aligned with yours”.

‘Triumph for Erdogan’ as US announces Syria pull-out

Mattis said he would stay through February to ensure an orderly transition.

Earlier on Sunday, Trump’s acting chief of staff said that Trump had known for “quite some time now” that he and Mattis “did not share some of the same philosophies … have the same world view”.

Mick Mulvaney told ABC’s “This Week” that the president and his defense chief “just could never get on the same page” on Syria, adding that Trump had said since his presidential campaign that “he wanted to get out of Syria”.

Shanahan (L) was a longtime Boeing Co executive [File: Joshua Roberts/Reuters]

Asked whether Trump wanted a Pentagon leader willing to challenge him or someone in lock step with his views, Mulvaney said “a little bit of both”.

“I’ve encouraged him to find people who have some overlap with him but don’t see the world in lockstep with him,” Mulvaney said.

Trump’s decision to pull US troops out of Syria has been sharply criticised for abandoning Washington’s Kurdish allies. Many also say the move will create the same conditions that gave rise to the Islamic State of Iraq and the Levant (ISIL, also known as ISIS).

Mattis, in his resignation letter, emphasised the importance of standing up for US allies – an implicit criticism of the president’s decision on this issue and others.

“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 wrote.

Another key player on the Middle East, Brett McGurk, also said he was leaving after years in charge of the war against the ISIL. He too opposed Trump’s new Syria policy.