SACRAMENTO (AP) — California’s public employees can’t pad their pensions by working extra hours and cashing out unused vacation and sick leave just before retiring, the state Supreme Court said in a ruling Thursday that gives a victory to local governments trying to contain spiraling pension obligations.

The court did not, however, wade into the bigger issue of whether governments can undo the so-called “California Rule” that dates to court decisions beginning in 1947 and holds that retirement benefits, once promised, cannot be touched.

READ MORE: State Sen. Wiener's Recovery Incentives Act Would Pay Meth Addicts to Stay Sober

The court found a provision of a 2013 law designed to limit “pension spiking” was “enacted for the constitutionally permissible purpose of closing loopholes and preventing abuse of the pension system,” Chief Justice Tani Cantil-Sakauye wrote in the unanimous ruling.

“Further, 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,” the court ruled.

Formulas for calculating pensions often include the average salaries for periods of employment, usually at the end of the workers’ careers.

By working extra hours and stockpiling vacation and sick time and then cashing out at retirement, some employees inflated their annual salaries and created pensions that were close to or even more than the salaries they made while working.

The California Rule ensures safe and predictable retirements for government workers. But it has limited how the state, cities, counties, schools, fire districts and others can respond to escalating pension costs spurred by generous benefits granted during better economic times and retirees living longer.

Former Gov. Jerry Brown supported the 2013 law and advocated for broader changes in the California Rule, but the justices did not touch its underlying protections.

“I think this is a big win for Jerry Brown and a big win for governments’ ability to manage pension liabilities reasonably,” said attorney Michael Colantuono, who filed a friend of the court brief in the case on behalf of the League of California Cities. “Government can change the rules, provided that it acts reasonably and for an important public purpose.”

Californians for Retirement Security, a 1.6 million member coalition of public employee unions and retirees, said the decision “unequivocally upholds the California Rule” even as it allows local pension officials to change certain previously promised benefits. The group’s chairman, Ted Toppin, in a statement called that part of the decision “unfair and unfortunate.”

READ MORE: Notorious Norteño Gang Member 'Lil Rhino' Sentenced For Carrying Out Jailhouse Attacks

The justices have long held that pension benefits granted to existing employees cannot be diminished unless they are replaced with similar benefits, but decided that protection does not prevent legislatively enacted reforms.

Thursday’s decision in a case brought by the Alameda County Deputy Sheriff’s Association against the Alameda County Employees’ Retirement Association upholds the government’s ability to regulate benefits, “while preserving the essential right to a meaningful pension,” Colantuono said. “The elimination of perceived abuses … violates nobody’s rights.”

The ruling incorporated two other similar legal challenges involving Contra Costa and Merced county employees.

Attorney David Mastagni, who represented the deputies’ association, did not immediately comment.

California’s high court last year unanimously upheld the 2013 pension reform law, ruling that buying additional retirement service credits is not one of beneficiaries’ legally protected “core pension rights.”

Cantil-Sakauye specifically noted in last year’s opinion that the court was not addressing or altering the California Rule.

The deputies’ union then argued in the current case that anyone hired before the law took effect in 2013 should still qualify for the enhanced pensions. The deputies contended that those were vested benefits and thus subject to the California Rule.

The state and local governments argued that the deputies did not have a vested, or guaranteed, right to the increased compensation, so the long-inviolate protections do not apply.

MORE NEWS: Santa Rosa Lawmaker Proposes Plan For City-Sanctioned Sideshows

About a dozen other states have similar pension guarantees.