The paradox of Jeff Sessions’s tenure as attorney general is that no other member of Donald Trump’s administration was so beleaguered and disparaged by the president, but no other member got as much done.

Even as he endured persistent verbal abuse from Trump, Sessions steamed forward on a range of conservative social-policy priorities, aggressively reorienting the Justice Department’s stances on immigration, civil rights, and criminal justice, among other issues. In an administration plagued by incompetent and ineffective figures, Sessions was a paragon of efficacy—a distinction that horrified his many opponents, but did nothing to win Trump’s trust or affection. The White House announced Wednesday that Sessions was resigning. The attorney general’s letter was not dated, and stated that he was stepping down at the president’s request.

Nothing illustrates Sessions’s effect as much as immigration policy. When it came time for Trump to pull the plug on the Deferred Action for Childhood Arrivals program, as he had promised he would during the 2016 campaign, the president got cold feet, but Sessions was happy to be the public face of the withdrawal. It was Sessions who tried to follow through (unsuccessfully) on Trump’s threat to cut off funding to sanctuary cities. It was Sessions who issued new guidance to immigration judges. And, most prominent, it was Sessions who went to the border to announce the Trump administration’s decision to separate migrant children from their parents. Sessions openly said the plan to split families up was intended to deter migrants, even as other administration officials said otherwise. The policy was met with widespread and appropriate horror, and Trump eventually pulled back—but he had backed the plan before that, and Sessions had followed through.

Sessions also led the charge to slow or reverse bipartisan momentum on criminal-justice reform. He reversed Obama-era guidance that instructed prosecutors not to seek the harshest penalties for drug offenses. He worked to block criminal-justice-reform efforts in Congress, drawing the ire of senators and representatives and eventually Trump himself. He took a harder line on marijuana legalization at the state level than the Obama Justice Department had. Where the DOJ had begun using its muscle to force local police departments to reform in cases of abuse, Sessions not only pulled back but tried to reverse existing reform agreements and made clear that police would receive a blank check from his Justice Department.

Sessions also rolled back a range of civil-rights protections. He ratcheted down voting-rights protections. He rescinded guidance to schools designed to protect transgender students. The DOJ also backed suits brought by Asian American students against universities, arguing that their affirmative-action policies were discriminatory.

In the midst of all of this, Sessions was subject to an almost constant stream of attacks from the White House. His relationship with Trump fell apart quickly after Sessions announced, in March 2017, that he would recuse himself from any matters involving Russia.

Trump was irate. “Look, Sessions gets the job. Right after he gets the job, he recuses himself,” Trump told The New York Timesin July 2017. “So Jeff Sessions takes the job, gets into the job, recuses himself. I then have—which, frankly, I think is very unfair to the president. How do you take a job and then recuse yourself? If he would have recused himself before the job, I would have said, ‘Thanks, Jeff, but I can’t, you know, I’m not going to take you.’ It’s extremely unfair, and that’s a mild word, to the president.”

Trump also attacked Rod Rosenstein, whom Sessions had picked as his deputy, suggesting (falsely) that Rosenstein was a Democrat and that no one knew anything about him. The attacks continued for months. Not since President Andrew Johnson fired Edwin Stanton in 1867 had a president so publicly feuded with one of his own Cabinet officials.

By summer 2017, it was clear that Sessions’s days were numbered. The Washington Post reported that he had offered to resign at least once, and it’s astonishing that he lasted so long.

One reason Sessions seemed content to withstand Trump’s disparagement was that he was able to move forward on many of his own policy goals. Sessions had long been an outlier in the Republican Party, especially on immigration; he was also far more open about his culture-war instincts on issues like sexuality and voting rights.

But these weren’t just Sessions’s pet issues. They were Trump’s as well. Hard-line immigration policies, giving police free rein, fighting phantom voter fraud—these were all signature Trump projects. Sessions had been the first U.S. senator to endorse Trump, and Trump took from him a range of policy concepts—especially on immigration—as well as a top adviser, Stephen Miller. But Sessions’s stewardship of those projects didn’t return him to favor with Trump, who, according to Bob Woodward’s book Fear, called Sessions “mentally retarded” and a “dumb Southerner.”

It’s instructive to compare Sessions with two other administration figures: Scott Pruitt and Don McGahn. Pruitt, the former administrator of the Environmental Protection Agency, was a disaster, an almost cartoonishly corrupt Cabinet official. But it took months of damaging headlines and congressional pressure to finally push Pruitt out. Meanwhile, he was surprisingly ineffective at actually enacting Trump’s environmental policies, attempting bold moves but repeatedly getting smacked down by courts for cutting corners.

Sessions had far more in common with McGahn, the former White House counsel. Like Sessions, McGahn came from the outer edges of the Republican Party, lacking the pedigree and connections of more establishment players. Both men rose to prominence in the Trump White House in a way they would not have under any other president. When McGahn’s departure was announced in August, I wrote that he’d been the most effective person in the West Wing, through his stewardship of judicial appointments. But Trump disliked and distrusted McGahn, and seemed eager to have him gone.

Of course, the same issue poisoned both Sessions’s and McGahn’s relationships with Trump: the Russia investigation, and especially Special Counsel Robert Mueller’s takeover of it. Trump was angry that neither man had protected him. He raged at Sessions’s lack of “loyalty” and complained that Attorney General Eric Holder had “totally protected” Barack Obama. (What he meant by that is unclear.) He twice instructed McGahn to fire Mueller, and McGahn twice refused, once threatening to resign.

Now both are gone. During a press conference Wednesday, Trump said he could remove Mueller at any time (a debatable assertion), but with Sessions gone, acting Attorney General Matthew Whitaker assumes control of Mueller’s probe. Whitaker was outspokenly critical of the special counsel’s inquiry before joining the administration, so Trump may now have a leader of the Justice Department who is more pliable on the Mueller front. But the president is unlikely to find an attorney general who will do as much to move his priorities forward as Sessions did—and the new attorney general will come into the job knowing that loyalty and efficacy aren’t enough to garner favor with Trump.

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

David A. Graham is a staff writer at The Atlantic, where he covers U.S. politics and global news.