Not long after Defense Secretary James Mattis returned to the Defense Department Thursday afternoon after a contentious meeting with President Donald Trump at the White House, he convened a meeting of his closest staff and advisers. His team knew something was amiss. Morale had been sinking at the Pentagon, following recent revelations that Trump had ordered a complete withdrawal of troops from Syria and planned to scale down forces in Afghanistan.

Mattis had opposed each of these decisions, and fought to overturn them. He told his team he could no longer work for the president. His last day in the Pentagon would be Feb. 28, 2019. “The building is in shock,” an Administration official told TIME.

News of the resignation sent chills through halls of the Pentagon, where Mattis has been a calming influence amid the constant tumult of the Trump presidency. The retired four-star Marine Corps general has spent the last 23 months of his tenure trying to thread the needle between implementing Trump’s policy objectives and maintaining long-standing American principles.

On at least a half-dozen substantive issues ranging from the importance of NATO to a transgender troop ban, Mattis has broken publicly with the president. Often he’s all that’s standing between allies and Trump-created-chaos. When the president was blasting NATO and cozying up to Russian President Vladimir Putin, Mattis began crisscrossing the globe to reassure European leaders that the world wasn’t turning upside down. He did the same after Trump’s face-to-face talk with North Korean leader Kim Jong Un. Within the military, he’s seen as a hard-charging, but scholarly figure that has tried to insulate the Pentagon from Trump’s knee-jerk instincts.

Although Mattis hasn’t won every argument, he’s limited the damage on many of them. That has made him an unusually consequential figure at a time of historic change around the world. China’s rise, Russia’s renewed adventurism and spreading global instability from record migration, mounting populism and emboldened authoritarianism were already putting pressure on the liberal international order that won the Cold War and advanced American interests for a half century. Trump’s embrace of that disruption at the expense of traditional allies only heightened the sense that liberal democracy was in danger. And it was Mattis who in word, deed and bearing was a constant figure of reassurance to America’s democratic allies that his country was bigger, stronger and more durable than Trump.

But ultimately, it was the abrupt decision to pull out all 2,200 troops fighting ISIS in Syria that pushed Mattis to the breaking point. To Mattis, the pullout was abandoning a key ally.

The Syrian Democratic Forces, a militia of mostly Kurdish and Arab fighters, has been a vital partner in the four-year-long war against the terror group. Mattis went to the White House Thursday to see if he could somehow ensure the forces’ protection in war-torn eastern Syria, where the group is besieged on all sides, particularly from Turkish forces to the north. But Trump refused to give Mattis any such assurances.

“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,” Mattis wrote in a resignation letter hand-delivered to the White House. “We must do everything possible to advance an international order that is most conducive to our security, prosperity and values, and we are strengthened in this effort by the solidarity of our alliances.”

The candid letter also criticized Trump’s attempt at warming relations with China and Russia, two nations Mattis referred to as “authoritarian” regimes that promote “their own interests at the expense of their neighbors, America and our allies.” Mattis added: “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.”

The Pentagon publicly released the letter shortly after Trump announced on Twitter that Mattis would step down.

“General Jim Mattis will be retiring, with distinction, at the end of February, after having served my Administration as Secretary of Defense for the past two years,” Trump wrote on Twitter. “During Jim’s tenure, tremendous progress has been made, especially with respect to the purchase of new fighting equipment. 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!”

The response to Matts’ resignation within the military and across Washington was a mix of surprise, sorrow and fear. “This is scary,” Democratic Senator Mark Warner from Virginia, vice chairman of the Intelligence Committee said on Twitter. “Secretary Mattis has been an island of stability amidst the chaos of the Trump Administration.” Senate Majority Leader Mitch McConnell of Kentucky said he was “particularly disturbed” by the news. Director of National Intelligence Dan Coats said Friday he was “deeply saddened” that Mattis was stepping down. “The experience and sound judgement that Secretary Mattis has brought to our decision-making process is invaluable,” he said. “His leadership of our military won the admiration of our troops and respect of our allies and adversaries.”

Astonishment has become a familiar sentiment at the Pentagon under Trump. New policy declarations, often made via Twitter, have caught military brass flat-footed: the withdrawal from Syria, the transgender troop ban, a proposal for a massive military parade and the decision to send thousands of active duty troops to the U.S.-Mexico border.

Mattis disagreed with Trump on all these issues, yet kept a low public profile to avoid the appearance of a clash. He took pains to avoid on-camera interviews and press briefings. He often slow-walked the president’s controversial orders or implemented them in a way that was less scandalous. After Trump declared that the U.S. should seize Iraq’s oil fields as compensation for military involvement, Mattis traveled to Iraq and made clear the U.S. government had no such plan.

“Policy by tweet is confusing to people and creates issues,” James Carafano, a vice president at the Heritage Foundation, a conservative think tank. “But Mattis’ vision of how this job works — non-partisan, staying above the political fray — that also creates issues for a president that values loyalty.”

While there were matters on which Mattis and Trump agreed, it was the president’s inclination toward “America First” isolationism that drove them apart. Trump has long pledged to scale back America’s military involvement around the globe. Meanwhile, Mattis has espoused a muscular role to advance U.S. interests overseas.

“Secretary Mattis had no choice but to resign. It is a loss for our country,” said Chuck Hagel, a former U.S. Defense Secretary, Republican Senator from Nebraska and Vietnam War veteran. “The continued exit of competent and experienced leaders in our government is dangerous. Our government is not a one man show. America is headed for a very difficult and messy next two years.”

When Trump first revealed Mattis as his pick to lead the Defense Department in December 2016, he compared him to Gen. George Patton, the legendary front-line general who helped liberate Europe in World War II.

Mattis served 44 years in the Marines before retiring in 2013. In his final three years in uniform, Mattis had headed U.S. Central Command and oversaw the wars in Iraq and Afghanistan as well as other military operations in the Middle East. Unmarried all his life, Mattis, 68, was known as a scholarly general who preferred being close to front-line combat, earning the nicknames “Mad Dog” and “Warrior Monk.”

Trump seized upon the nickname “Mad Dog,” (even though Mattis loathes it) and Mattis became a close adviser to the president. He would present his advice amid frequent visits to the White House during the first year of the Administration.

This year, however, his influence steadily waned. With the firing of Secretary of State Rex Tillerson in March, Mattis lost his closest ally in the Administration. A month later, National Security Advisor H.R. McMaster, a retired Army lieutenant general, also left. At the end of the year, John Kelly, a retired Marine general, will step down as Trump’s chief of staff.

Questions began swirling about Mattis’ future in May when Trump tore up the nuclear deal with Iran, a document that Mattis had vehemently defended. A month later, Mattis found out that Trump halted all U.S. military exercises with South Korea as a concession to North Korean leader Kim Jong Un. Then in June, Trump ordered Mattis to make the Space Force a sixth branch of the military, despite Mattis’ public criticism on the idea. More recently, Mattis advised Trump to select Air Force Gen. David Goldfein, as the next chairman of the Joint Chiefs of Staff. Trump instead chose Army Gen. Mark Milley.

The final rebuke came Wednesday when Trump announced that all U.S. troops would be pulled from Syria. In April, Mattis had convinced Trump to allow U.S. forces to finish the fight against ISIS. This time around, however, there was no opportunity for debate, and Mattis was soon on his way out the door.

Get our Politics Newsletter. The headlines out of Washington never seem to slow. Subscribe to The D.C. Brief to make sense of what matters most. Please enter a valid email address. Sign Up Now Check the box if you do not wish to receive promotional offers via email from TIME. You can unsubscribe at any time. By signing up you are agreeing to our Terms of Use and Privacy Policy . This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply. Thank you! For your security, we've sent a confirmation email to the address you entered. Click the link to confirm your subscription and begin receiving our newsletters. If you don't get the confirmation within 10 minutes, please check your spam folder.

Write to W.J. Hennigan at william.hennigan@time.com.