The endgame is here for Gov. Jerry Brown’s long-running battle with the courts over prison overcrowding.

On Monday, a three-judge panel of the U.S. District court gave Brown the two-year extension he was looking for, but he had to pay the price. And it was a steep one.

The governor agreed to accept the court’s long-standing ruling that the state’s prison population has to be capped at 137.5 percent of design capacity, or just over 112,000 inmates. He also has to immediately implement ways to get the 5,000 or so inmates over that limit out of the system, using methods like more “good time” credits for non-violent prisoners, faster parole for “two-strike” offenders and expanded parole for sick and elderly inmates.

That’s bad enough for a governor who has angrily vowed that he would never “turn over California’s criminal justice policy to inmate lawyers who are not accountable to the people.” But Brown also had to allow a federal compliance officer, pointedly not accountable to the people, to be the lone judge of whether the state is meeting its part of the inmate reduction bargain.

This compliance officer, the justices wrote, “will have the authority to release prisoners should (the state) fail to reach one of the benchmarks” for trimming the number of inmates.

To add insult to injury, Brown also had to agree not to challenge any decision made by that compliance officer.

The extension order came in response to a final standoff between Brown and the judges, who since 2009 have been calling on the state to take measures that they believe “would have safely reduced the California prison population and alleviated the unconstitutional conditions of medical and mental health in the prisons.”

But when Brown said the only way to do that quickly would be to ship thousands of prisoners to lockups outside the state, the judges balked. That frequent flyer prisoner plan didn’t meet the court’s demand for a “durable” solution to the overcrowding problem and would cost millions of dollars that could otherwise be used for rehabilitation and anti-recidivism programs that can, eventually, permanently lower the state’s prison population.

Brown tried his best to put a favorable sheen on the court’s decision, calling it “encouraging” and arguing that it gives California “the time and the resources necessary to help inmates become productive members of society and make our communities safe.”

But California voters, led by law-and-order GOP legislators, have made it clear that they don’t want lawbreakers, even purportedly rehabilitated ones, released early so they can move back into their communities. And if the overflow of inmates can’t stay in state prisons or be shipped across California’s borders, the only alternatives involve sending them to local jails or putting them back on the streets, two very politically unpopular moves.

The soaring prison population can be blamed largely on a “lock ‘em all up” mentality among state voters, who over the years have backed “three strikes” and a variety of other tough sentencing rules. Calling for a do-over, as the court has urged and many Democratic legislators seem to support, won’t go far if voters aren’t ready to go along with that change.

Brown has a right to be grumpy about the court’s take on the overcrowding problem, which often seems to ignore the political realities that Brown and every other governor in the country have to deal with every day.

It’s easy for judges to say that many states “have come to realize that, properly handled, the release of prisoners held past the time necessary to serve the purpose of their incarceration will not result in danger to the community, but rather may actually benefit both the prisoners and their communities.”

But try selling that to voters worried about having their homes burglarized, their cars broken into or being robbed on the street.

Judges, though, will argue that their job is to determine whether the Constitution is being followed. Getting that done is Brown’s concern.

The governor can’t argue that he didn’t see this final step coming. Over the years, each new court order has been testier and testier, with the judges essentially saying, “Solve this problem now or else.”

While reluctantly granting the two-year extension to eliminate overcrowding, the judges said that “California prisoners deserve far better treatment” then they have received from the state and blamed the financial and social cost to California’s citizens on Brown’s “heretofore unyielding resistance to compliance with this Court’s orders.”

That’s not to say the judges didn’t allow for some self-criticism.

“We recognize that this Court must also accept part of the blame for not acting more forcefully with regard to defendant’s obduracy in the face of its continuing constitutional violations,” they said in their order.

Those aren’t the words of someone willing to spend any more time playing around and the governor finally seems to recognize that. It’s way past time for him to stop fencing with the court and start working on the best and safest way to trim California’s prison population.

John Wildermuth is a longtime writer on California politics.