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.

CLICK HERE TO GET THE FOX NEWS APP

"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 politicians, 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.

Rep. Joyce Beatty, D-Ohio, suggested it was "safe to assume" Mattis disagrees with Trump's withdrawal of troops from Syria.

Rep. Mike Turner, R-Ohio, credited Mattis for rebuilding the nation's military and his commitment to making the world safer.

"Our military has been rebuilt under Secretary Mattis's leadership. He has been a strong partner in working with Congress as a force of reason to robustly support our troops in grave and perilous times," Turner tweeted.

Rep. Adam Schiff, D-Calif., used the announcement to fire at Trump.

"Old Marines never die, but they do resign after the President ignores their advice, betrays our allies, rewards our enemies, and puts the nation’s security at risk. Turn out the lights when Mattis leaves; we will not see his like again while Trump remains in office," he tweeted, sharing Trump's tweet announcing Mattis' departure.

Sen. Chris Murphy, D-Conn., pointed to potential fallout from Mattis stepping down.

"Just imagine the morale crisis at the Department of Defense right now, having sustained the 1-2 punch of the Syria reversal and Mattis resignation. Devastating," he wrote.

Murphy also called it a "security crisis."

Speaker of the House Paul Ryan said Congress is "indebted" to Mattis for his service.

"With our country’s defense in his hands, we have become a safer America at home, and a more commanding force abroad. His patriotism and grit are matched only by his humility and graciousness," Ryan tweeted.

Senate Majority Leader Mitch McConnell in a statement said he thinks its critical for the country to "maintain and strengthen the post-World War II alliances," while also acknowledging who our "friends and foes" are, adding that Russia is "among the latter."

“So I was sorry to learn that Secretary Mattis, who shares those clear principles, will soon depart the administration. But I am particularly distressed that he is resigning due to sharp differences with the president on these and other key aspects of America’s global leadership," McConnell said.

He went on to encourage the president to choose a replacement "who shares Secretary Mattis’s understanding of these vital principles and his total commitment to America’s servicemembers."

House Democratic leader Nancy Pelosi described Mattis as being "a comfort" to those who were worried "about the path the Trump Admin would choose to take."

"His resignation letter is defined by statements of principle — principles that drove him to leave the Administration," she tweeted. "All of us should be concerned at this time."

Former Vice President Joe Biden said on Twitter that while he and Mattis have had different opinions in the past, they always agreed "that respect for our allies and a commitment to the most important and effective alliances in history made America safer."

"It is clear this administration has abandoned those core American beliefs," he continued. "Secretary Mattis’ presence and his voice of reason and experience will be missed in the Pentagon and the Situation Room."

Trump said Thursday that Mattis' replacement "would be named shortly."

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

Here's a look at some other reactions from lawmakers.

Fox News' Elizabeth Zwirz and The Associated Press contributed to this report.