Follow CBSPHILLY Facebook  | Twitter

WASHINGTON (CBS News) — Defense Secretary James Mattis will resign at the end of February, he informed President Trump in a letter Thursday. The defense secretary said he is stepping down because of the differences in viewpoints with Mr. Trump.

“Because you have the right to have a Secretary of Defense whose views are better aligned with yours on these and other subjects, I believe it is right for me to step down from my position,” Mattis wrote.

Mr. Trump announced the news in a tweet and praised Mattis’ tenure as secretary.

“During Jim’s tenure, tremendous progress has been made, especially with respect to the purchase of new fighting equipment,” Mr. Trump wrote on Twitter. “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!”

News of Mattis’ impending departure comes the day after Mr. Trump’s sudden announcement about Syria, a decision he made without consulting security officials in his administration.

A senior White House official said that Mattis came to the White House for a meeting, not previously scheduled, around 3:30 p.m. Thursday, and informed the president he would be leaving. The president hopes to announce a replacement by the end of the year.

Mattis also appeared to be subtly criticizing Mr. Trump’s “America first” foreign policy in his resignation letter, discussing the importance of maintaining alliances.

“One core belief that I have always held is that our strength as a nation is inextricably linked to our unique and comprehensive system of alliances and partnerships,” Mattis wrote. He also warned against closeness with countries such as Russia and China.

“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 added, perhaps a rebuke to Mr. Trump’s lack of foreign policy expertise.

Mattis was considered to be one of the few cabinet officials to whom Mr. Trump would listen, although his influence over the president had waned in recent month. Mattis, along with departing chief of staff John Kelly, was one of the military men tapped for an administration position by Mr. Trump, who fondly referred to them as “my generals.”

Mattis is the latest of these former generals to leave the administration, along with Kelly and former National Security Adviser H.R. McMaster. Mattis was reported to have agreed to a “suicide pact” with former Secretary of State Rex Tillerson and Treasury Secretary Steve Mnuchin last year, in which the three agreed to leave the administration if one was forced out.

Mr. Trump’s first two years in office have seen significant upheaval in his cabinet. The Trump administration has had three chiefs of staff, three national security advisers, two secretaries of state, two Homeland Security secretaries, two Health and Human Services secretaries and two VA secretaries. There are currently vacancies for the posts of attorney general, UN ambassador, Interior secretary and Defense secretary.

Mr. Trump’s tweet comes amid negotiations to pass a partial government funding bill.

© 2018 CBS Interactive Inc. All Rights Reserved.