During the 2016 presidential campaign, James Mattis predicted that he would be courted to serve in a Hillary Clinton administration in the likelihood that she would win the presidency. Instead, Mattis ended up working nearly two years as Secretary of Defense for Donald Trump, a president who routinely undermined his own national security team and would mock Mattis by calling him a “Democrat” or “Moderate Dog.”

Mattis' resignation on Thursday, though abrupt, came as no surprise to those who knew him and had worked alongside him in the Pentagon.

In a series of meetings with colleagues at the beginning of the administration, Mattis said he was originally surprised to get a call from the Trump team asking him to take the post of defense secretary, according to two sources with who attended those meetings. He told several people that had Clinton won the election, he thought he would have agreed to serve on her team.

According to three former Clinton campaign advisers, the former secretary of state and Mattis had a very positive relationship, predating the campaign. Though no final decisions were made on who would serve as the defense secretary in a Clinton administration that never happened, Mattis was still someone Team Hillary regarded highly.

Mattis and senior Clinton staffers stayed in touch during the presidential campaign, and the former advisers said they solicited his advice on foreign policy and national security matters. The 2016 Clinton team even tried to recruit Mattis to publicly endorse Hillary for president against Trump. According to two of these sources, he politely declined, though conveyed to the campaign his respect for Clinton.

A spokesman for the Department of Defense did not immediately respond to a request for comment.

Though he declined the overture, the rapport that Mattis enjoyed with Clinton would underscore just how criminally out of place he was while serving with the man who beat her. The policy chasm between Trump and his defense secretary has been abundantly evident, on everything from intra-administration debates on the Iran nuclear agreement, towards troop level decisions in Syria and Afghanistan, and even Trump’s desired Washington, DC, military parade.

As reported in Bob Woodward’s book FEAR earlier this year, Mattis even took it upon himself to actively ignore an order from President Trump to have Syrian dictator Bashar al-Assad assassinated. “Let’s fucking kill him! Let’s go in,” Trump reportedly exclaimed to Mattis after a chemical attack on civilians in Khan Sheikhoun.

Trump killing Assad, in the middle of Syria’s years-long, extremely brutal civil war, would have marked a dramatic escalation of the conflict, especially in terms of U.S. intervention—deeper involvement that Trump now says he’s dead-set against. Ironically, one of the final straws that sparked Mattis’s decision to leave the administration was Trump ordering a pullout of U.S. forces in Syria.

“I think he’s sort of a Democrat, if you want to know the truth,” President Trump said of Mattis, during a 60 Minutes interview in October.

The personal and professional friction came to a head late this week. Mattis’ resignation letter conspicuously offered not a hint of glowing praise for the 45th president, and made clear his displeasure with the direction of the administration and its foreign policy.

“The most decorated Marine and thought leader on the military basically just said, ‘Fuck this,’” a source close to Mattis told The Daily Beast shortly after his announced resignation on Thursday.

People close to Mattis say that he is making his move now not only because of his policy differences with Trump, but because he doesn’t want his reputation obliterated by the Trump era. One of those sources who has worked with Mattis said the outgoing defense secretary is highly cognizant of how the stature of other high-ranking members of the administration has been irreparably damaged by this president, and that Mattis has stayed extremely vigilant to “do everything possible not to end up in the same heap.”

Another source, a former senior Pentagon official close to Mattis, told The Daily Beast that he was surprised the defense secretary didn’t step away from the job sooner, and that it made sense for him to leave now.

“I think Mattis is reading the tea leaves here,” that source said. “He’s leaving in part because he knows what’s coming and he wants to be able to work after this craziness ends.”