US secretary of defence Jim Mattis has delivered a farewell message to troops and civilian personnel, urging them to “keep the faith in our country”, as he leaves the job.

Mr Mattis sent in his resignation letter on December 20, just after Donald Trump announced he would withdraw troops from Syria. Mr Mattis disagreed with that, as well as many other of the president’s military policies.

In that resignation letter, Mr Mattis acknowledged the disagreements. “Because you have the right to have a secretary of defence whose views are better aligned with yours on these and other subjects,” he wrote. “I believe it is right for me to step down from my position.”

Mr Mattis’ last day was officially Monday, when the Pentagon will mark the transition of power. When Mr Mattis leaves, deputy defence secretary Patrick Shanahan will take over, at least temporarily, as acting defence secretary.

In his resignation letter, Mr Mattis said his views were not in line with those of Mr Trump, to the chagrin of the president. Mr Trump said that he hated the resignation letter, which criticised his military choices, but he hated media coverage of it more.

In his message on Monday, Mr Mattis said the department's “leadership, civilian and military, remains in the best possible hands”.

In spite of Mr Mattis’ confidence in Mr Shanahan, the deputy director does not have experience governing international affairs or counterterrorism, CNN reported. Instead, he has focused on internal reform, budget issues, and the proposed Space Force.

Support free-thinking journalism and attend Independent events