Chief Justice John G. Roberts Jr. just preserved the right to an abortion in America. For now. In a development that was only surprising if you aren’t familiar with how Roberts operates in the Trump era, he joined with the court’s liberals to strike down a Louisiana law restricting abortion rights.

It was not, we should be clear, because Roberts does not think Roe v. Wade should be overturned. He almost certainly does. He may take the opportunity to do so, if the timing is right. But now is not that moment.

Roberts has an ideology, but he is not an ideologue. He is an extremely savvy political operator, one who carefully sides with liberals when he determines that it is necessary to save the Republican Party from itself. Which is what he just did.

Roberts knows that the timing could not be worse for the Supreme Court to overturn Roe, or even to gut it without explicitly overturning it, as conservatives wanted to do with this case. The party that nurtured and raised him up is in a position of extraordinary peril, and if it is not restrained, it could destroy its political prospects for years or even decades, which would dramatically undermine the conservative legal project to which Roberts is devoted. He isn’t going to let that happen.

First, let’s look at this case, called June Medical Services v. Russo.

It was essentially a replay of a case called Whole Women’s Health v. Hellerstedt that the court decided in 2016, in which they struck down a Texas TRAP law, short for “targeted regulation of abortion providers.” June Medical concerned a nearly identical law in Louisiana, but the big difference is that in 2016, Justice Anthony M. Kennedy — who supported abortion rights — was still on the court, and today his seat is held by Brett M. Kavanaugh.

The idea of TRAP laws is that while Roe v. Wade prevents states from outlawing abortion outright, they can achieve nearly the same outcome if they make it impossible for abortion providers to operate, by imposing regulations so onerous almost no clinic can meet them. The most common regulation in TRAP laws is the admitting privileges requirement, which says that you can only perform abortions if the physician doing so has admitting privileges at a nearby hospital. This has precisely zero medical justification; in this case, Louisiana was unable to provide evidence of even a single case where a woman got worse care because her doctor didn’t have admitting privileges.

As everyone knows, the idea that the legislatures that enact TRAP laws are trying to protect women’s health is a cruel joke. But Justices Thomas, Alito, Gorsuch and Kavanaugh don’t care; they’re clearly eager to reverse Roe as soon as possible, and will sign off on any state law that restricts abortion rights.

But Roberts has a longer view. And this is an election year.

“I joined the dissent in Whole Woman’s Health and continue to believe that the case was wrongly decided,” the chief justice wrote in his concurrence. But “The legal doctrine of stare decisis requires us, absent special circumstances, to treat like cases alike.”

In other words, he lost the argument in 2016, but since the court ruled, he is obligated to uphold that precedent and vote to strike down the Louisiana law since it’s almost identical to the Texas law they previously struck down.

But it’s also important that in 2016 Roberts was in the minority, and because the outcome didn’t hinge on his vote, he didn’t have to worry about any practical effect of the position he took. Now he does.

There’s no reason to think Roberts has changed his views on the constitutionality of abortion or state laws that restrict it. He took the narrowest possible grounds on which to rule against the Louisiana law. And as Ian Millhiser explains, he hinted in his concurrence that he takes a dim view of Planned Parenthood v. Casey, which established that states can’t create an “undue burden” on a woman’s right to choose. It was almost an invitation for someone else to challenge Casey in the future. Say, after this election is over.

Now imagine that Roberts had ruled with the conservatives. It would have given Republican-run states the green light to enact almost any TRAP law they want.

Require that any doctor who performs abortions must have a last name beginning with the letter X? The clinics can only open between 4 and 4:15 a.m. on Feb. 29 of a leap year? All patients must prove they are of sound mind by reciting pi to 500 places before they can get their abortion? Why not?

Okay, I’m exaggerating a bit. But what matters is that had Louisiana prevailed, the decision would have been greeted by screaming headlines reading “Supreme Court Restricts Abortion!”, and those new state TRAP laws would be enacted within days, if not hours. It would be seen, quite properly, as a backdoor way of outlawing abortion — and as Roberts is surely aware, around two-thirds of Americans oppose overturning Roe v. Wade.

That would then cause an enormous backlash, at a moment when the Republican president already trails his Democratic opponent by around nine points in polls, a huge deficit.

If Trump wins in November, there will be another vote or two on the court to repeal Roe — which would make Roberts not the swing vote that decides it, but the sixth or seventh for repeal. That’s a position he’s probably much more comfortable with. On the other hand, if Trump loses badly, Democrats could hold the presidency for eight or 12 years.

That would mean a more liberal court over the long run, one that not only protects abortion rights but threatens the project about which Roberts clearly cares much more: advancing the interests of corporations and the wealthy.

Conservatives, of course, will see no such nuance in Roberts’s approach. They will cry that he is a traitor to their cause and see this as more motivation to reelect Trump so more Kavanaughs can be put on the bench. Liberals, meanwhile, will breathe a sigh of relief and not see the courts as anything to get too excited about.

That too may have occurred to the chief justice, helping to convince him that the interests of the Republican Party were far better served by letting the liberals win this case. If he is a prophet without honor in his party, it’s a role to which he has grown accustomed.

Watch Opinions videos:

Read more: