California got more than some extra time when a federal court extended a Dec. 31 deadline to reduce its prison population.

The judges gave the state an opportunity.

After two decades, the focus of this marathon legal battle may finally be shifting to a long-term solution.

Gov. Jerry Brown and his three immediate predecessors contested inmate lawsuits alleging inadequate health care and dangerous overcrowding in state prisons. Time and again, they lost.

In 2009, a panel of federal judges concluded that overcrowding was preventing inmates from receiving adequate health care in violation of their constitutional rights.

They ordered the state to reduce its prison population to 137.5 percent of design capacity, a decision affirmed by the U.S. Supreme Court. The justices refused to intervene when the Dec. 31 deadline was imposed.

The legal battle is over. What remains is a determination of how the state will comply.

After last-ditch legal appeals failed, Brown proposed to send about 9,600 inmates to private prisons, county jails and out-of-state lockups, spending a big chunk of the state's budget surplus in the process.

Using that approach, the state would hit the mark by Dec. 31. But not for long.

That's where the judges come in.

Their frustration with the state's intransigence is well known. Earlier this year, when Brown declared the prison crisis over and called for an end to federal oversight, the judges threatened to hold the governor and other state officials in contempt if they didn't come up with a plan to comply with the court's order.

So it wouldn't have been a surprise if the judges refused to grant the state any more time.

Instead, they recognized, in their words, the potential for a "a durable solution to the prison crowding problem."

The framework for a solution emerged in the closing days of the legislative session and envisions spending more on intervention, mental health and rehabilitation programs to reduce recidivism and, in turn, the need for more and more prison space.

The judges gave the state until Jan. 27 to meet with inmate lawyers and said they might extend that deadline further if progress is being made.

The court also gave some directions, saying discussions about reducing prison crowding should cover juvenile offenders serving lengthy sentences, inmates being held for federal immigration authorities, elderly and infirm inmates and three-strikes inmates eligible for early release under an initiative approved by voters in 2010.

Senate President Darrell Steinberg, who pressured Brown and other state officials to consider a more comprehensive approach, assured the judges in a letter that "many of these remedies could be put into place relatively quickly."

California simply can't afford to build more prisons or to keep renting more and more space to incarcerate inmates. The time has come to explore ways to prevent some of the crimes that land people in prison. The federal judges have thrown a lifeline. The state needs to grab it.