Jeff Sessions has resigned as President Trump’s Attorney General, after months of harassment. But his legacy is going to get the last laugh. If President Trump and all his appointees left office tomorrow, instead of Sessions, the mark Sessions has left on policy would be the most enduring.

While other Cabinet officials have gotten sucked into White House drama or caught in their own venal scandals, Sessions has generally kept his attention on doing his job — even at the cost of his relationship with the president. He’s pulled every available lever to redirect the considerable resources of the Department of Justice (DOJ) to fight the crimes he considers most serious: violent crimes, drug crime, and, most notably, violations of immigration law.

The DOJ’s role in the immigration system isn’t widely understood, but it’s crucial. Illegal entry and reentry aren’t just the most commonly prosecuted federal crimes — they make up a majority of all federal convictions. The litigation the DOJ chooses to file can help tilt the balance between state, federal, and local governments as the three try to negotiate who gets to help — or has to help — enforce immigration law. Perhaps most importantly, the part of the deportation process that has so far posed the biggest obstacle to mass deportation — the immigration court system — is under Sessions’s control.

Sessions, at heart, is a prosecutor. He understands the complicated and sensitive legal system he currently wields power over as well as anyone — but he understands it as a weapon with which to protect America against people who would do it harm. And while his peers in the Republican Party tried to strike a balance between “good” legal immigrants and “bad” illegal ones, he has always taken a skeptical attitude toward immigrants and immigration, period, believing that the burden of proof ought to be on an immigrant to prove that she deserves to come to or stay in the US, and preferring, always, to keep worthy people out rather than let anyone unworthy in.

Immigration brought Trump and Sessions together. The issue has defined both their political careers: Trump’s, short but meteoric, through the Republican ranks in the 2016 presidential campaign and into the White House; Sessions’s, a decades-long sojourn in the wilderness of immigration hawkishness while the Republican Party retained some moderation on the issue throughout the Bush and Obama years.

Trump gave Sessions a legacy, bringing the Republican Party closer to him. Then Sessions spent two nearly-thankless years laboring to give Trump one, using every power he possessed as attorney general to ensure that the scales of justice tip toward punishment of unauthorized immigrants as often as possible.

Jeff Sessions’s entire career built toward the task of “ending illegality” in immigration

In an administration whose most senior policy officials are either total policy neophytes (Ben Carson, Jared Kushner) or at least unaccustomed to the stakes and scrutiny of federal policymaking (Ryan Zinke, Scott Pruitt, John Kelly), Jeff Sessions stood apart. He has spent decades in the business of federal law, as a federal prosecutor and senator.

It’s no coincidence that Sessions was the anomaly in Trump’s Cabinet, the seasoned vet in a clubhouse full of rookies. Sessions is among the few veterans of Republican Party governance who could serve helpfully in a Trump administration, because his policy positions weren’t mainstream among congressional Republicans until Trump came along.

Sessions has long been particularly concerned about immigration to America, in ways most Republican policymakers simply were not. He often found himself leading a faction of his own party — often a small one — against bipartisan efforts endorsed or at least tolerated by Republican leadership. In 2013, during the Senate’s most recent comprehensive immigration reform fight, Sessions took a lonely stand against the bipartisan “Gang of Eight” immigration bill in the Senate Judiciary Committee — and then had to quarterback the bill’s opponents on the Senate floor when then-Minority Leader Mitch McConnell declined to steer his caucus one way or the other on the bill.

Part of what distinguished Sessions from other Republicans was his skepticism not just of illegal immigration but of all immigration. As Sessions has put it, more people want to move to the United States than the country could ever possibly accept; the dividing line between whom the country should accept and whom it shouldn’t, he believes, should be determined by the American people based on who they feel serves the “national interest” — defined as assimilating into American culture and helping the fortunes of American workers.

The other part, subtler but no less important, was his attitude toward unauthorized immigrants. Sessions isn’t just an immigration hawk who rejects “amnesty” for unauthorized immigrants who have settled in the US; he has long advocated that the federal government has an obligation to “end illegality” in the immigration system, full stop.

Other immigration hawks — most notably President Trump himself — seize on specific high-profile incidents to make their points: A caravan of a few hundred Central American asylum seekers becomes a symbol for a tide of dubious asylum claimants; a particularly gruesome MS-13 murder becomes evidence that “sanctuary cities” should be eradicated.

Sessions has generally preferred a logical, categorical approach: The problem with unauthorized immigration is that it is illegal, and that illegality itself causes real pain to American citizens. Because Sessions doesn’t rely on “bad” unauthorized immigrants to make his point, he doesn’t open the door for sympathy toward “good” ones.

Trump took to Twitter to reassure DACA recipients that they’d be able to stay; it was Sessions who made the case to the public that, in fact, it was better for America that they leave.

On one side, Sessions believes, stand “special interests” like immigrant advocacy groups, unions, and corporations. On the other side stand “the American people,” who are personally afflicted by unauthorized immigration, and rank-and-file immigration agents who were (before Trump) ignored by their own superiors in Washington. And in Sessions’s view, elected officials have too often landed on the wrong side.

“The American people have pleaded with us to end the illegality,” he argued on the Senate floor during the 2013 immigration debate, “and create a lawful system that serves the national interest — a system we can be proud of. And for 30 years, Congress has failed.”

The Republican Party has come to Sessions. In 2014, he was named the head of the immigration subcommittee of the Senate Judiciary Committee. The following year, Donald Trump seized momentum in the Republican presidential primary by attacking immigration as a threat to Americans’ personal and national security, and Sessions saw an opportunity. He was among the first members of Congress to endorse Trump. He and his staff took the lead in writing policy proposals. And when Trump was elected, Sessions was named to one of the most powerful positions in the federal government.

Jeff Sessions took control of the system that is key to mass deportation

In Trump’s first year, arrests of unauthorized immigrants by Immigration and Customs Enforcement (ICE) agents (responsible for immigration enforcement in the “interior” of the US, away from the border) spiked 41 percent — nearly enough to make up for a steep decline in the number of immigrants crossing the border and getting caught by Border Patrol.

But the Trump administration can’t arrest its way to mass deportation. It has to fix the immigration court system. And Jeff Sessions knew that very well.

Immigrants arrested within the US are entitled to a hearing in immigration court — and that legal process can stretch on for months, even years. The backlog of pending immigration court cases is now over 650,000. The average case currently pending in court has been pending for 711 days. And because immigrants who’ve been living in the US for longer and don’t have criminal records are likely to fight deportation harder and longer, arresting more of those immigrants — as ICE is doing — is likely to swell the backlog even more than arresting the same number of immigrants with criminal records would.

In speeches, Sessions characterized immigration courts as gummed up by frivolous asylum claims and sabotaged by “dirty immigration lawyers” trying to sneak their clients into legal status they don’t deserve. (Among a certain group of immigration lawyers, “dirty immigration lawyer” has become a “nasty woman”–like badge of honor.) He made it clear not just that immigration courts aren’t moving quickly enough, but that people who deserve to be deported aren’t getting deported quickly enough (or at all).

But Sessions didn’t use his leadership of the DOJ simply to make the immigration court system more efficient. He used the full extent of his power as attorney general to reduce the likelihood that a case gets resolved (quickly or otherwise) in an immigrant’s favor — removing tools and resources that make courts more efficient but improve immigrants’ odds of winning their cases, while pressuring immigration judges to plow through cases at an unheard-of rate. He removed the safety valves from the pipeline while increasing the pressure.

Thanks to Sessions, judges are forced to decide immigrants’ fate in a matter of hours

In early April, the DOJ sent a memo to all immigration judges telling them that “efficiency” would now factor into their performance reviews. The DOJ set standards that it called “benchmarks”: Judges would need to complete at least 700 cases a year to earn a “satisfactory” rating, while completion of fewer than 560 cases would lead to a judge being deemed “unsatisfactory.”

Immigration judges and lawyers assailed the “benchmarks” as quotas. But a DOJ source shrugged about the new directive to the Washington Post, saying that 700 cases was only “three cases a day.” The National Association of Immigration Judges, the judges union, estimates that when you account for the days court isn’t in session and other factors, it’s more like four cases a day.

“Anecdotally,” said judges union head Ashley Tabaddor this spring, “we’re not aware that this is a number that is even close to being reasonable.”

The “benchmarks” get into the details of court proceedings too. In cases where the judge has to review the judgment of an asylum officer about whether an asylum seeker can claim a “credible” fear” or “reasonable fear” of persecution or torture, the DOJ says the judge should be able (85 percent of the time) to make a decision that same day.

Immigration lawyers worry that they simply can’t put together a compelling case in that time. “Often [you need] documents from overseas that take time to get, documents from hospitals in other countries, to document your persecution claim,” says Karen Lucas of the American Immigration Lawyers’ Association.

Immigration court cases are famously complex — if a judge considers all the possible outcomes. But if she’s just rubber-stamping deportations, they go much faster. And immigration judges and lawyers alike are deeply concerned that at the pace of three or more rulings a day, there is no way for immigration court to become anything other than a deportation assembly line.

Sessions worked to reduce options for judges and immigrant defendants

At the same time that the DOJ told judges that cases need to go faster, though, it made moves to eliminate some things that allowed cases to go faster but made it more likely that immigrants won.

In April, for example, the DOJ announced abruptly that it was suspending a program that offered group “legal orientation” workshops to immigrants in detention centers — explaining to them how court hearings worked (necessary because there’s no right to a lawyer in immigration court) and what options they might have to prevent a deportation order.

The DOJ claimed it was “pausing” the legal orientation program to evaluate its effectiveness. But the lead contractor, the Vera Institute for Justice, says they received an email from DOJ telling them “there is not intent that the program will be renewed.”

The Vera Institute was blindsided — not least because the legal orientation program had been evaluated in 2012, and found to make the system more efficient. Because immigrants weren’t fighting hopeless cases, court cases took an average of 12 fewer days to resolve and the government saved an average of six nights in detention costs — for a total savings of $17.8 million a year over and above the cost of administering the orientation.

“This seems totally contrary to the Department of Justice’s interests,” Oren Root of Vera told Vox in April. “Their biggest problem, from their point of view, is getting cases concluded. And here is a tool that is proven by their own study to be effective in doing that.”

The DOJ reversed its decision to suspend legal orientations under pressure from members of Congress. But it re-evaluated the program’s effectiveness — and found, in a report with what the Vera Institute called “insurmountable flaws,” that it was actually a cost-waster for the federal government.

There’s a similar pattern in the cases that Sessions referred to himself for review from the Board of Immigration Appeals, a tactic he used aggressively in the second half of his short tenure. In May, Sessions ruled that judges couldn’t move cases off their docket by closing them without a deportation order — and opened the door to the reopening of 350,000 cases that had already been closed this way.

Sessions proceeded to put severe constraints on judges’ ability to grant asylum to victims of violence from non-state actors (like domestic abusers or gangs), and limit judges’ abilities to delay a hearing to let the immigrant apply for legal status elsewhere. At the time of his resignation, his office was working on new opinions in cases regarding whether asylum-seekers had the right to a bond hearing and whether judges could dismiss their cases without a hearing at all.

All these changes, and threatened changes, to immigration courts would create a ratchet. Judges would have to get through more cases due to the “performance measures,” without being able to move cases off their docket by closing them — their primary tool of docket control over the past few years. They’d have to make rulings in asylum cases more quickly, without giving immigrants time to present evidence, and without being able to grant asylum on the basis of domestic violence. They’d have to find time for hopeless cases that immigrants might not have tried to fight if they had gone through “legal orientation” — taking time away from cases immigrants could actually win if given the chance.

Sessions reshaped the DOJ, and the Trump administration, in his image

None of this was the work of someone content to grab a few headlines every couple of months by giving a red-meat speech about lawless immigrants. It was the work of an attorney general who understands the immigration system exceedingly well and is devoted to wreaking as much change in it as possible.

Every Trump administration initiative on immigration, to the extent that it’s had teeth at all, has been given those teeth by Sessions and the DOJ.

The first iteration of the “travel ban” was too legally flimsy to live. The second and third versions were worked over by Sessions’s Office of Legal Counsel and have now been in place in some form since June 2017.

The decision to rescind the Deferred Action for Childhood Arrivals (DACA) program was delivered by Sessions, and his DOJ is continuing to fight it in court in the face of several judicial setbacks.

Both the DHS and the DOJ were legally directed to deny grants to “sanctuary cities,” but only the DOJ has aggressively tried to do it — though that, too, has been smacked down in the courts. And while Trump threatens to pull ICE out of California and praises Texas for being tough on immigration, it’s Sessions’s DOJ that’s waging the battles over what cities can be compelled to do on immigration enforcement — though, again, unsuccessfully so far.

It was also Sessions who issued a memo directing US attorneys to prosecute every immigrant referred to them by DHS for the federal misdemeanor of “illegal entry” — giving teeth to an otherwise unrealistic promise from Trump to end “catch and release.” And while Trump (and DHS) are blamed for the widespread use of family separation this spring and early summer, Sessions’s “zero tolerance” policy, as announced to great fanfare in San Diego in May, was what turned family separation into a matter of standard practice for immigrants who cross into the US illegally rather than waiting at a port of entry like a road checkpoint.

Without Sessions, initiatives like these — things that are easy to proclaim but harder to follow through on — might collapse into mere symbolism, like the US-Mexico border wall.

But it would be a mistake to bet on it.

Sessions has already seeded the federal government with his outlook and knowledge. As much as his fingerprints are all over the Trump administration’s immigration policy — at least the parts that work — not all of those fingerprints are being left by Sessions himself; many are being left by staff he mentored or worked closely with, now in seats of power throughout the government.

First and foremost, of course, is Stephen Miller, who served Sessions for years before joining the Trump campaign but appears to have succeeded where Sessions failed in retaining Trump’s ear.

In the DOJ, there’s longtime staffer Gene Hamilton, who masterminded the end of DACA as a DHS adviser and then moved to DOJ to reunite with his old boss. Another former Sessions staffer, Alan Hanson, runs the Office of Justice Programs — responsible, among other things, for disbursing local and state law enforcement grants.

And then there are the staffers from elsewhere on the Hill who worked closely with Sessions when he was the leading (and arguably only) immigration restrictionist in the Senate — and therefore an intellectual center of gravity. US Citizenship and Immigration Services Director L. Francis Cissna and adviser Kathy Nuebel Kovarik were both on the staff of the Senate Judiciary Committee when Sessions chaired its immigration subcommittee. Dimple Shah, an adviser at DHS headquarters, worked for Rep. Bob Goodlatte (R-VA), the House Judiciary Committee chair who revealed himself during his tenure as a closet immigration hawk, championing bills written by a staff who worked closely with Sessions on strategy (and who were reportedly involved in the drafting of the first travel ban).

Sessions’s influence could even extend beyond the political appointee layer of the federal government, into the civil service itself. Democrats in Congress claim they’ve heard disturbing reports from whistleblowers: that the DOJ is withholding or rescinding hiring offers to would-be immigration judges and members of the Board of Immigration Appeals, “based on the perception that candidates hold political or ideological views that do not align with those of the Trump Administration.” In a request to the DOJ inspector general, Democrats concluded that “in multiple cases, the Department appears to have withdrawn offers of employment with explanations that suggest a pretext for improper political motives.”

Given that the DOJ has hired over 100 new immigration judges to address the court backlog, ideological discrimination in hiring those judges would amount to court-packing — and would color the bench of immigration courts for decades.

On immigration, there have usually been two types of people in the Trump administration: the hawks who know what they’re doing, and the people who defer to the hawks. Sessions didn’t just lead the hawks — he stocked their ranks so fully that they can continue without him. Meanwhile, beyond the tweets and bombast, the machine that sends immigrants from arrest to deportation will clank along with alarming efficiency until it’s stopped by a new administration — long after Sessions is gone.