From the day Jim Mattis took over the Pentagon, he was seen by Washington and the world as a safeguard against a president addicted to chaos and animated by a different moral code.

At home, he was the seasoned battlefield commander who was willing to check Trump’s often-impulsive instincts when it came to deploying force. As long as Mattis was at the helm of the Pentagon, Republicans and Democrats trusted there was someone who would fight to ensure military actions weren’t taken on a whim.

Overseas, Mattis was perhaps the only Trump administration official who had the unconditional trust of America’s closest allies.

“Having Mattis there gave all of us a great deal more comfort than we have now,” said Sen. Jeff Flake (R-Ariz.). “He was the steadiest hand in the Cabinet, and we’ve all slept better and felt better that he was there.”

Mattis’s resignation letter not only offered a window into his policy disagreements with President Trump but also seemed to question Trump’s fitness to be commander in chief at a dangerous moment on the world stage.

Mattis referred to a “resolute and unambiguous” leadership style that he had sought to embody, particularly when dealing with threats posed by countries such as Russia and China. Unstated, but implied, was that Trump’s erratic and impetuous approach to foreign policy isn’t up to the threats America faces.

The pointed letter set off alarm in the capital.

Senate Majority Leader Mitch McConnell (R-Ky.) called Mattis's dismissal "regrettable" and seemed to echo Mattis's criticism of Trump's leadership by urging the president to replace his defense secretary with someone who has an equally "clear-eyed understanding of our friends and foes, and recognize that nations like Russia are among the latter."

Sen. Mark R. Warner (D-Va.) declared the defense secretary’s departure to be “scary,” and House Minority Leader Nancy Pelosi (D-Calif.) declared herself “shaken” by the news.

Other Republicans were more measured, stressing disappointment rather than fear. “Great sadness” were the words that Sen. Lindsey O. Graham (R-S.C.), a longtime ally of Mattis and recent partial convert to Trumpism, used on Thursday evening.

In an administration that has seen unprecedented turnover, Mattis’s conclusion that he could no longer work with Trump is likely to alter the course of the administration’s foreign policy more than any other departure.

In Europe and Asia, Mattis often traveled in Trump’s wake and calmed allies who were unnerved by the president’s threats to abandon allies who didn’t pay more for their defense. His decades of service and commitment to alliances reassured allies who were put off by Trump’s tendency to kowtow to strongmen, such as Russia’s Vladi­mir Putin or Turkey’s Recep Tayyip Erdogan, and insult traditional partners in Canada and Great Britain.

As time passed, though, it became increasingly clear that Mattis’s worldview couldn’t be reconciled with Trump’s “America First” vision of a strong and powerful military that would smite enemies with overwhelming force and then return home, leaving others to clean up the mess. The defense secretary retreated from public view both at home and overseas. Mattis’s closest allies, many of whom had served with him in the Pentagon, insisted that he would never resign and that Trump wouldn’t fire him.

Mattis, meanwhile, tried to publicly play down disagreements.

In his resignation letter, though, the untenable nature of their differences was made abundantly clear. Their immediate break appeared to occur over policy in Syria and Afghanistan, missions that Trump saw as wastes of American blood and treasure.

Mattis, by contrast, believed that an American presence was needed to prevail over international terrorist groups in both countries, and give the United States and its allies the necessary leverage to negotiate a lasting peace.

But Mattis’s disagreements ran much deeper than policy in Syria or Afghanistan. His resignation letter, which the Pentagon released publicly after Trump tweeted about the former general’s impending departure, suggested that the two men were at odds over how America should handle great powers such as Russia and China.

“It’s 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 interests,” Mattis wrote. He advocated an approach to the world that envisioned the United States employing its military power, its economic strength and its network of global alliances to thwart Russia’s and China’s global ambitions.

For much of the past two years, senior White House officials insisted that Trump backed this approach, even if the president never seemed to state it publicly.

“This just blows that out of the water,” said Thomas Wright, a senior fellow at the Brookings Institution. “He’s not committed to countering or challenging Russia and China. We now have that in writing from the secretary of defense.”

Republicans who have backed a more traditional American foreign policy in the mold of Ronald Reagan or George H.W. Bush sounded a similar alarm.

“Secretary Mattis was giving advice the president needs to hear,” Sen. Ben Sasse (R-Neb.) said. He called Mattis’s decision to leave “a sad day for America” and warned that Trump’s preferred policy of isolationism “is a weak strategy” that will harm the country and its allies.

There were Republicans who applauded Mattis for departing before his reputation was sullied. Rep. Adam Kinzinger (Ill.), himself a military veteran, said that Mattis’s “resignation is an act of patriotism, standing for our American principles above all else.”

Mattis remains popular within the military and with veterans who cheered his tough but pithy aphorisms. Asked last year what keeps him awake at night, Mattis replied almost instantly: “Nothing. I keep other people awake at night.”

Mattis’s acrimonious departure will not only make it difficult for Trump to find a new secretary of defense but also potentially dissuade others from serving in the administration. His service in the Pentagon provided a fig leaf to traditional Republican foreign-policy experts who had reservations about working for Trump.

“He was a symbolic figure,” said Eliot Cohen, a senior official in the George W. Bush State Department. He described the former Marine general as an example to those who were uneasy about Trump but believed that “service to country” and “patriotic duty” compelled them to work for the president.

In an administration mired in investigations, Mattis oversaw a Pentagon notably free of scandal. One of his most memorable moments came early in the administration at a Cabinet meeting when Mattis was the only secretary or senior official who declined to lavish Trump with praise. Instead, he spoke of his pride in leading America’s military.

“He was an example of someone who could retain his character while serving an entirely unqualified and despicable human being,” Cohen said. “The overall caliber and character of those who are still willing to serve will be abysmal.”