US President Donald Trump and Deputy Secretary of Defense Patrick Shanahan attend a cabinet meeting at the White House in July. Photo: AFP

Donald Trump announced on Sunday that he would replace Defense Secretary Jim Mattis with his deputy Patrick Shanahan, days after the outgoing Pentagon chief quit over differences with the US president on key policy issues.

Mattis, 68, had said he would leave at the end of February to facilitate a smooth transition for the next chief of the world’s biggest military power – but Trump accelerated the process amid reports that he was upset over media coverage of the stinging resignation letter the former Marine submitted.

The announcement that Mattis would leave came right after Trump surprised Washington and its allies abroad by announcing that US troops would leave Syria and significantly withdraw from Afghanistan.

Mattis and others had strongly counseled the frequently impulsive president against those moves – and the decorated retired general did little to conceal his disagreement with Trump.

“Because you have the right to have a secretary of defense whose views are better aligned with yours,” Mattis said in the letter, “I believe it is right for me to step down from my position.”

He added, “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 these issues.”

Shanahan spent over three decades working for aircraft giant Boeing, including as vice president and general manager of Boeing Missile Defense Systems, before moving to the Pentagon as deputy in 2017.

– with reporting by Agence France-Presse