The California Supreme Court on Thursday ruled against public employee unions that were trying to beat back part of former Gov. Jerry Brown’s pension overhaul law.

The court’s ruling prohibits so-called pension spiking, a strategy in which county public workers took extra shifts, worked odd hours at higher pay or cashed out accumulated leave at the end of their careers to inflate their pensions in retirement.

The Alameda County Deputy Sheriff’s Association filed a lawsuit in 2012 over Brown’s law, the Public Employees’ Pension Reform Act, known as PEPRA, to try to keep counting those types of pay as pensionable. A Merced County union filed a similar lawsuit, and was among the plaintiffs in the case.

The state, first under Brown and then under Gov. Gavin Newsom, pressed for the court to use the occasion to broadly address the California rule, a set of legal precedents dating to the 1950s that have protected public pensions from reductions without new and equal benefits.

State attorneys argued governments need more flexibility to reduce future pensions for current workers in order to manage budgets during difficult economic times.

The court, in a unanimous ruling, rejected that approach, issuing a narrow ruling focused on a collection of county-run pension systems.

“We have no jurisprudential reason to undertake a fundamental reexamination of the (California) rule,” Chief Justice Tani Gorre Cantil-Sakauye wrote in the decision.

The court said Brown’s state law didn’t violate contracts by amending the law governing the county systems even though the change affects employees hired before Brown’s law went into effect on Jan. 1, 2013.

The court found that Brown’s law clarified existing rules and closed loopholes rather than introducing more substantial new changes, which the court called a “proper objective” in keeping with legislators’ lawmaking authority.

“It would defeat this proper objective to interpret the California rule to require county pension plans either to maintain these loopholes for existing employees or to provide comparable new pension benefits that would perpetuate the unwarranted advantages provided by these loopholes,” Cantil-Sakauye wrote in the court’s decision.

Ted Toppin, chairman of Californians for Retirement Security, said the court’s decision undermines promises made to the Alameda deputies but protects benefits for most California public workers.

“For the vast majority of public employees, having the California rule upheld is a good thing and comforting and ensures them that the retirement security they were counting on will be there,” Toppin said.

The court issued a similarly narrow ruling in a pension case a year ago in affirming the state’s authority to eliminate another benefit, an option workers had had to purchase service credit to boost their pensions instead of working the time.

By sidestepping the California rule in both cases, the court blocked any obvious avenues for local governments or the state to pursue cost-saving changes to their pension systems, said Steve Berliner, an attorney who represents public agencies for Los-Angeles based law firm Liebert Cassidy Whitmore.

“There could be other circumstances where there are similar types of spiking that may be subject to further pension reform and under this ruling would appear to be something that can be changed,” Berliner said. “But I don’t know that simply saving money because the pensions cost so much is going to pass muster with this court.”

While the lawsuit centers on county-run pension systems that are independent of the largest statewide plans, the case drew support and opposition from dozens of groups because of its implications for the California rule.

Union attorneys argued that when public employers hire workers, the employers are contractually bound to calculate new workers’ pensions upon retirement under the same terms that applied when they were hired.

Brown’s legal team, led by attorney Rei Onishi, argued pensions are more like other types of pay that are subject to change. State attorneys have said governments need flexibility to modify benefits to protect the “integrity and solvency” of pension systems.

Onishi defended the law again under Newsom, arguing in May that the issues in the case had “never been more important” as governments weigh furloughs and budget cuts in response to the economic effects of the coronavirus.

Since then, state lawmakers have worked to close a projected $54 billion deficit for the year ahead. Local governments are facing their own budget challenges because of the new recession, which are compounding existing concerns about the increasing shares of their budgets that pensions are taking up.

Union attorneys have argued that if the courts weaken pension protections, elected officials will favor political priorities over workers’ promised benefits.

Alameda is among 20 counties, including Sacramento County, with retirement plans governed by the County Employees Retirement Law. Public employee groups from Contra Costa and Merced counties also filed lawsuits over Brown’s pension law that were appealed. The Supreme Court combined suits from those two counties with the Alameda case.