By Jennifer Earl, Fox News–

Defense Secretary James Mattis gave President Trump his notice on Thursday — a move that has given lawmakers across both sides of the aisle some cause for concern. In a signed resignation letter, which was released by the Pentagon, Mattis said he would remain in the role through Feb. 28, closing out a 2-year working relationship with Trump.

The announcement came a day after Trump surprised U.S. allies and members of Congress by announcing the withdrawal of all U.S. troops from Syria, and as he continues to consider shrinking the American deployment in Afghanistan.

In a lengthy letter to the president, Mattis alluded to potential disagreements with Trump. In particular, Mattis said the U.S. should be cautious when communication with countries that are “increasingly in tension with ours,” citing Russia and China.

“It is clear that China and Russia, for example, want to shape a world consistent with their authoritarian model – gaining veto authority over other nations’ economic, diplomatic, and security decisions – to promote their own interests at the expense of their neighbors, America and our allies. That is why we must use all the tools of American power to provide for the common defense,” Mattis wrote, in part.

In conclusion, Mattis said Trump had the right to work with a defense secretary “whose views are better aligned with yours on these and other subjects,” adding that stepping down from his post is the “right” thing to do.

News of Mattis’ upcoming departure shocked some lawmakers, who scrambled to decipher the reasoning behind it.

Sen. Marco Rubio, R-Fla., praised Mattis’ work ethic, admitting “he will not be easy to replace.”

“For the sake of our national security I hope his decision to resign was motivated solely by a desire to enjoy a well deserved retirement,” he added in a tweet.

Sen. Mark Warner, D-Va., called the announcement “scary.”

“Secretary Mattis has been an island of stability amidst the chaos of the Trump administration. As we’ve seen with the President’s haphazard approach to Syria, our national defense is too important to be subjected to the President’s erratic whims,” Warner wrote on Twitter, sharing a copy of Mattis’ resignation letter.

Sen. Rob Portman, R-Ohio, thanked Mattis for his lifetime of service, which, he said we’ve “benefitted immensely” from.

“As #SecDef, he has led efforts to rebuild our military, defeat #ISIS & keep the American people safe. He is a patriot and I thank him for his service,” he said.

Rep. Steve Scalise, R-La., said Mattis was truly an “American hero.”

After reading Mattis’ letter to the president, Rep. Don Beyer, D-Va., emphasized Mattis’ words.

“In his resignation letter, Mattis wrote that Trump has “the right to have a Secretary of Defense whose views are better aligned with yours on issues including ‘treating allies with respect,'” Beyer repeated, calling the letter a “stunning rebuke.”

Sen. Lindsey Graham, R- S.C., announced Mattis’ departure in “sadness” Thursday, calling him one of the country’s greatest military leaders.

“General Mattis is a combination of intellect and integrity. He has been in the fight against radical Islam for decades and provided sound and ethical military advice to President Trump. He is a role model for the concept of Duty, Honor, Country,” Graham added.

Graham recently blasted Trump for his decision to pull troops out of Syria, calling it an “Obama-like decision.” In return, Trump fired back at the politician — who has voiced his support for the administration in the past — in a tweet, saying it was difficult to understand why Graham would be against saving countless lives.

“So hard to believe that Lindsey Graham would be against saving soldier lives & billions of $$$. Why are we fighting for our enemy, Syria, by staying & killing ISIS for them, Russia, Iran & other locals? Time to focus on our Country & bring our youth back home where they belong!” Trump tweeted.

This is a developing story.