Thursday afternoon, Defense Secretary Jim Mattis resigned after two years of frequent policy friction with the commander in chief. Only a day earlier, President Trump overruled Mattis and many others serving in senior national security roles by announcing a wholesale withdrawal of U.S. troops from Syria.

Mattis’s resignation comes shortly after the president announced that another of his once-favored advisers, John F. Kelly, a retired general, will step down as chief of staff at the year’s end.

Whatever Mattis’s immediate reasons for resigning, he and Kelly have already let Trump use their military credentials for political purposes. The president once bragged that his cast of military figures was “going to keep us so safe,” making them central to his administration’s discourse. And when they have failed to support him, he has cast them as his political opposition — tarnishing the military’s image as above the civilian fray. And that has pushed observers to worry about the partisan politicization of the military itself.

Observers of civil-military relations have written at length that a norm of nonpartisanship is essential to the military’s credibility. Here are three big reasons that this latest personnel upheaval shows how difficult it is to keep the military looking nonpartisan in the age of “Trump’s generals.”

1. Trump has pushed retired and active-duty military leaders into taking political positions, either supporting or opposing him

Trump not only appointed many high-profile ex-military officials to government, but he also frequently appealed to those officials to endorse his policies and asked the military to implement them. In some cases, Trump wanted to use the military’s credibility to support political policies. For instance, right before the midterm election, when Trump and right-wing media were warning that a caravan of migrants was trying to “invade” the United States, the president ordered several thousand U.S. troops deployed to the southern border, a surprising attempt to use the military for what would ordinarily be considered a law enforcement effort.

As secretary of defense, Mattis went along with not just the pre-election border deployment but also other requests. For instance, last month Mattis, along with Secretary of State Mike Pompeo, went to Congress to support the president’s contention that there was no “smoking gun” evidence that Saudi Crown Prince Mohammed bin Salman was responsible for the killing of journalist Jamal Khashoggi.

The uniformed military has at times taken the opposite position from that of the president. For instance, after a white supremacist rally in Charlottesville ended with one woman dead, Trump commented that there were “some very fine people on both sides.” Within 24 hours, the service chiefs issued statements denouncing racial violence and extremism, which many observers perceived as a “rebuke by the top brass of their commander in chief.”

2. Trump used partisan language to discredit ex-military officers who disagreed with him

With many Republican national security experts unwilling or unable to serve the incoming Trump administration, appointing ex-military officers served a dual purpose of filling seats and pleasing fans. The military institution has long polled as among the most trusted institutions in U.S. society — especially among Republicans. My research has found that Republicans do not readily absorb or accept negative information about the military.

That meant that to disagree with “his” generals, the president felt he had to discredit them to his military-friendly Republican base. And so before Trump warned in October that Mattis might leave, he called the secretary “sort of a Democrat.” And after retired Adm. William H. McRaven called Trump a threat to democracy for denigrating the news media, Trump denounced him as a “Hillary Clinton fan.”

3. The retired military elite has become politically engaged

Retired senior military officers have increasingly taken to a wide variety of media to voice political opinions, a trend that has intensified in recent years. They’ve been cable news commentators for a while. And they’ve been taking to social media, political scientist Heidi A. Urben finds, cultivating increasingly partisan followings there. Retired generals like Jerry Boykin or Mike Flynn have backed the president there; others like William McRaven, Barry McCaffrey and Mark Hertling have spoken out against his policies across an even wider array of media.

Mattis’s resignation, Kelly’s ouster, Flynn’s prosecution and former Interior Secretary (and ex-Navy SEAL) Ryan Zinke’s resignation while under investigation may be signs that the Trump administration’s overreliance on ex-military appointees has failed.

Even so, all this politicization will surely damage the military’s credibility as a nonpartisan institution that stands apart from civilian politics.

Michael A. Robinson (@m_robinson771) is an Army captain and assistant professor of international affairs at the U.S. Military Academy at the U.S. Military Academy. He holds a Ph.D. in political science from Stanford University, where his research focused on elite credibility, partisan polarization, and civil-military relations.

The views expressed are those of the author and do not reflect the official policy or position of the Department of the Army, the U.S. Military Academy, the Defense Department or any part of the U.S. government.