US Defence Secretary James Mattis is resigning, the latest in a string of senior US officials to do so.
His announcement came a day after President Trump said he was withdrawing troops from Syria – a decision General Mattis is understood to oppose.
In his resignation letter, Gen Mattis strongly hinted at policy differences with Mr Trump.
He said the president had the right to appoint someone “whose views are better aligned with yours”.
Gen Mattis, 68, will leave the job in February. President Trump has not immediately named a successor, but said one would be appointed shortly.
Members of Congress from both sides of the political divide have reacted with shock to the resignation.
Senate Majority Leader Mitch McConnell, from Mr Trump’s own Republican Party, said he was “distressed” to hear the resignation was reportedly due to “sharp differences” that Gen Mattis had with the president.
What did the resignation letter say?
Gen Mattis alluded to disagreements with the president in a number of policy areas.
In his letter, addressed to Mr Trump directly, he described his views on “treating allies with respect” and using “all the tools of American power to provide for the common defence”.
“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,” he wrote.
While not mentioning the Syria troop pull-out directly, Gen Mattis had previously warned that an early withdrawal from the country would be a “strategic blunder”.
He also appeared to point to differences on a number of other key issues, including Russia and Nato.
“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,” Gen Mattis wrote.
He confirmed he would continue in the role until the end of February to “allow sufficient time for a successor to be nominated and confirmed”.
A protest resignation, plain and simple
Analysis by Anthony Zurcher, BBC News, Washington
Donald Trump may try to spin James Mattis’s departure as a retirement after a lifetime of government service. It’s not. This is a protest resignation, plain and simple.
The defence secretary’s letter to the president – in which he offers full-throated support for a US network of alliances and calls for a policy of containment of authoritarian rivals – makes that perfectly clear.
The timing of this announcement, just a day after Mr Trump abruptly ordered the withdrawal of US troops from Syria and amid rumours of an Afghanistan pullout, should also dispel any doubt about stark policy differences between the two men.
Gen Mattis had positioned himself as one of the cooler heads throughout the president’s term – considered by Democrats and Republicans alike as a “grown-up” in the room and a far cry from the “Mad Dog Mattis” nickname that so enamoured Mr Trump.
From his Pentagon office across the Potomac River from the White House, he managed to stay largely above the fray, frequently assuaging the concerns of US allies unnerved by some of the president’s more intemperate statements.
Now that check on the president, one of the last few remaining, is heading out, suggesting turbulent waters ahead.
What other response has there been?
Florida Senator Marco Rubio, who ran against Mr Trump for the Republican nomination in 2016, said the letter “makes it abundantly clear that we are headed towards a series of grave policy errors which will endanger our nation, damage our alliances & empower our adversaries”.
Mr McConnell tweeted his statement responding to the announcement.
John Kasich, Ohio’s Republican governor, described current events surrounding the Trump administration as “chaos”.
Democratic Senator Mark Warner, who is vice chair of the Senate Intelligence Committee, labelled the development “scary”.
He described Gen Mattis as “an island of stability amidst the chaos of the Trump administration”.
Democratic House Minority Leader Nancy Pelosi told US media she was “sad” and “shaken” by the news.
She also described Gen Mattis as a “comfort to many of us as a voice of stability in the Trump administration”.
What is the latest on withdrawals?
Mr Trump announced his decision to withdraw some 2,000 US troops from Syria on Wednesday, asserting that the Islamic State (IS) group had been defeated there.
The move is reportedly at odds with the view of some of his key cabinet officials.
It has also drawn criticism from some of the country’s international allies.
Separately on Thursday, there were reports the White House was also planning a sharp cut to troop numbers in Afghanistan.
The reports, which suggest 7,000 could return home, have not been confirmed by officials.
Republican Senator Lindsey Graham tweeted that any withdrawal of troops there would be a “high risk strategy” which could reverse US progress in the region.