jim mattis
US Secretary of Defense Jim MattisMark Wilson/Getty Images [Representational Image]

Defence Secretary James Mattis has resigned, telling Donald Trump in a letter that he should choose a person who is more in tune with his world view after the US president decided to withdraw American troops from Syria.

Trump announced the resignation in two tweets on Thursday evening, and said Mattis, will leave at the end of February. Mattis was a great advocate of India-US defence relationship.

According to reports, 68-year-old Mattis went to the White House on Thursday afternoon in a last attempt to convince Trump to keep US troops in Syria. He was rebuffed and told the president that he was resigning as a result.

In his extraordinary resignation letter, Mattis told Trump he had "the right to have a Secretary of Defence whose views are better aligned with yours".

Mattis' resignation letter, a Pentagon spokeswoman said was hand-delivered to the president. In the letter, Mattis told Trump it was the "right time" for him to step down.

"The end date for my tenure is February 28, 2019, a date that should allow sufficient time for a successor to be nominated and confirmed as well as to make sure the Department's interests are properly articulated and protected at upcoming events to include Congressional posture hearings and the NATO Defense Ministerial meeting in February," Mattis said.

The Pentagon chief did not mention if he was resigning specifically over the troop withdrawal decision, which has surprised US allies and several lawmakers.

Analysts say the withdrawal of troops will please US enemies by clearing the way for Syria's Bashar al-Assad regime, Russia and Iran. Mattis had warned that removing ground forces from the Middle Eastern country would be a "strategic blunder".

Currently, there are about 2,000 US forces in Syria. After Mattis sent his resignation, Trump said, "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.

"During Jim's tenure, tremendous progress has been made, especially with respect to the purchase of new fighting...," he said on Twitter. Mattis and Trump reportedly have had differences on several foreign policy matters, including Syria and Afghanistan.

Reports say the president is also considering a drawdown of US troops from the 17-year-long conflict in Afghanistan. Mattis said in his resignation letter that he believes the US must be resolute in its approach to countries whose strategic interests are increasingly in tension with America's.

"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," he stressed.

"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," he added.

Mattis is the latest in long-list of senior Trump administration officials to leave or be removed. In March, Trump fired Secretary of State Rex Tillerson.

On Thursday, Trump praised Mattis for his service and for being a "great help" to him in getting allies and other countries "to pay their share of military obligations". He said a new secretary of defence will be named shortly.

Defending his decision on Thursday to withdraw US troops from Syria, Trump tweeted that the US does not want to be the "policeman" of the Middle East.

In his resignation letter, Mattis said, "Like you, I have said from the beginning that the armed forces of the United States should not be the policeman of the world.

"Instead, we must use all tools of American power to provide for the common defence, including providing effective leadership to our alliances." Mattis' celebrated military career spanned four decades.

Prior to joining Trump's Cabinet, the four-star general was the head of US Central Command, which directs military operations and oversaw the wars in Iraq and Afghanistan.

He was known before and during his White House tenure for his even-keeled demeanour and strategic mind and is broadly held in high esteem among Republicans and Democrats alike.

"I'm shaken by the news because of the patriot that Secretary Mattis is," said House Minority Leader Nancy Pelosi.