Kevin Lamarque / Reuters

In the spring of 2016, not long after The Atlantic published an article I had written about President Barack Obama’s foreign-policy record, I visited the Hoover Institution, a think tank on the campus of Stanford University, where James Mattis had sequestered himself in exceedingly comfortable exile. He was writing a book, teaching a bit, and trying to suppress, with intermittent success, the resentment he felt toward President Obama and his national-security team.

Obama had removed Mattis, a four-star Marine general, as head of U.S. Central Command three years earlier. The president and his advisers had found Mattis too militant, too insistent, on matters related to Iran. “Iran, Iran, Iran,” Mattis told me. “That’s the threat, but I think people got tired of listening.”

Stanford is serene and manicured and moneyed, and Mattis was very obviously enjoying himself. “It’s like I died and went to heaven,” he told me one afternoon as we walked to lunch, “and in heaven the weather is perfect.” But this was the first time I had seen Mattis since publishing my interviews with President Obama, and he was full of acid thoughts on the subject.

In these interviews, Obama outlined his understanding of America’s role in the world. He didn’t portray himself as a declinist, exactly, and he certainly wasn’t isolationist, though he was a bit too recessive and lawyerly for Mattis’s taste. What provoked Mattis’s particular dismay, however, was the manner in which Obama talked about America’s allies. His criticism of France, Great Britain, and various Arab allies of the United States as “free riders”—he was upset at their lackadaisical efforts in Libya, and in NATO—became a global controversy.

“Your article was really long, and so I was printing it while I was working out,” Mattis said. “I got off the machine to read some pages, and I thought I had got some printouts mixed up. I thought I had printed out things that Trump had said, not President Obama.” At the time, Donald Trump was emerging as the probable Republican nominee for president. “I went through it carefully, and I saw that it really was Obama calling our allies ‘free riders.’ He sounded like Trump. Here’s a sitting U.S. president calling our allies ‘free riders.’ That’s pretty bad, insulting our allies.”

My conversation with Mattis that day on the Stanford campus might as well have taken place in a different epoch, or on a different planet. It’s quaint to think that the mild, calibrated criticism Obama directed at a set of allies who probably deserved it could have triggered the outcry it did. And in the spring of 2016, virtually no one in the American national-security establishment had yet imagined that Donald Trump—the target of Mattis’s scorn and derision that day—would become president, and make his task the dismantling of the American idea.

I tell this story because it underscores a salient point: James Mattis understood from the beginning the nature of Trump’s intellectual, ideological, and characterological defects, even as he was pulled into Trump’s orbit, and into his Cabinet.

Mattis, in his retirement years, had built a good life for himself. But when the call came, he chose, one more time, to serve. There is no doubt in my mind that he would have preferred to serve President Hillary Clinton. But patriotic duty is patriotic duty, and he did his, the day he joined Trump’s team. And he did his patriotic duty again on Thursday, when he decided he could take no more.

The critique of Trump contained in Mattis’s extraordinary resignation letter is not centered on policy disputes. He had a set of policy and personnel arguments with Trump, of course. He felt particularly aggrieved by Trump’s decision earlier this month to appoint Army General Mark Milley as the next chairman of the Joint Chiefs of Staff. (General David Goldfein, the Air Force chief of staff, was Mattis’s top choice.)

But the Mattis critique is foundational: The president he serves, he suggests in his letter, does not understand the value of allies, or the immorality of disparaging and abandoning them. Trump, as my colleague David Frum notes, is abandoning America’s Kurdish allies in Syria to extremism and terror, and he is abandoning Afghanistan to the Taliban. Mattis always knew that Trump lacked an understanding of why autocracy is the enemy of the American idea. But Mattis operated under the illusion that he could change Trump’s views, or at least some of his foolish ways. Yesterday marked the end of the illusion.

Mattis’s departure also means that the United States is entering the third phase of Trump’s foreign policy. In the first year of his presidency, Trump paid attention mainly to domestic issues, and did not afflict America’s diplomatic and national-security establishment with an undue number of his ignorant and damaging foreign-policy views. In the second year, he became more destructively engaged, but he listened, on occasion, to those in his administration who possessed actual expertise in foreign policy. We are now entering the third year of his presidency, and the third phase of his foreign policy: Trump alone, besieged, but believing, perhaps more than ever, in the inerrancy of his beliefs.

James Mattis knew who Trump was, and joined him anyway, because he is a patriot. And because he is a patriot, he would have remained with Trump if he thought he could influence Trump’s policies. But whatever influence he had, he lost.

And now the dangerous part begins.

We want to hear what you think about this article. Submit a letter to the editor or write to letters@theatlantic.com.