Secretary of Defense James Mattis will retire at the end of February after two years in the job, President Donald Trump revealed on Twitter Thursday evening.

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…. — Donald J. Trump (@realDonaldTrump) December 20, 2018

….equipment. General Mattis was a great help to me in getting allies and other countries to pay their share of military obligations. A new Secretary of Defense will be named shortly. I greatly thank Jim for his service! — Donald J. Trump (@realDonaldTrump) December 20, 2018

“Because you have the right to have a secretary of defense whose views better align with yours….I believe it is right for me to step down from my position,” Mattis wrote in his resignation letter to Trump. Mattis outlined his view that “a nation is inextricably linked to the strength of our unique and comprehensive system of alliances and partnerships.”

MATTIS resignation letter: “Because you have the right to have a secretary of defense whose views better align with yours….I believe it is right for me to step down from my position” pic.twitter.com/R09bWcxb0j — Saagar Enjeti (@esaagar) December 20, 2018

“We must do everything possible to advance an international order that is most conducive to our security, prosperity, values, and we are strengthened in this effort by the solidarity of our alliances,” he continued. (RELATED: Here’s How Mattis Will Implement Trump’s Transgender Troop Ban For Now)

Mattis was one of the first cabinet secretaries announced by Trump during the presidential transition in 2016, cherishing his wartime nickname of “Mad Dog.” Mattis has served as a quiet and effective advocate of the president’s agenda at the Pentagon since taking its helm two years ago.

The defense secretary frequently stayed out of the limelight during his tenure, preferring to save any advice or criticism for the president in private. Mattis at times disagreed with Trump’s foreign policy instincts and fought to have the U.S. remain engaged in foreign conflicts like Afghanistan, Iraq, and Syria.

Trump’s decision to announce Mattis’s retirement comes as he has decided to withdraw all U.S. forces from Syria in the next 30 days. Mattis is said to have advised Trump against the decision.

WATCH: