Stockton’s bankruptcy is headed to a historic ruling Wednesday, when a judge is expected to decide whether the city can reduce its payments to CalPERS and scale back the pension benefits that have been promised to city retirees and active employees.

After months of buildup, U.S. Bankruptcy Judge Christopher Klein is likely to rule on a protest filed by one of Stockton’s creditors, Franklin Templeton Investments. Franklin said the city can’t continue paying its full pension contribution every year to CalPERS while offering a meager payout on the $36 million owed to the investment firm.

At a July 8 hearing, Klein hinted that he was sympathetic to Franklin’s view. “I might be persuaded that … the pensions can be adjusted,” he said.

It’s not at all certain whether Stockton would reduce its pension payments, even if Klein says it can. Under state law, CalPERS says it would have no choice but to end Stockton’s pension plan. Pension benefits would drop by an estimated 60 percent, which city officials believe would trigger a mass exodus by police officers and other employees.

Premium content for only $0.99

Regardless of what Stockton does, CalPERS has been fighting strenuously to avoid a legal ruling that says pension contributions are no longer untouchable. The giant pension fund’s lawyers say CalPERS is merely trying to protect a system that serves the public well.

“Pensions secure financial futures and help the state and its local subdivisions recruit and retain valuable public servants,” CalPERS’ lawyers said in a recent court filing. “Putting a cloud over public pensions only invites worry and uncertainty about the security of those pensions.”

Public pensions have been considered ironclad for generations. State legislatures are free to reduce benefits for new workers, as California did in 2013, but it’s long been agreed that promises made to existing employees and retirees must be kept.

Those legal protections, however, have been under duress ever since Stockton filed for bankruptcy protection in 2012. Several of the city’s Wall Street bond creditors, who lent the city more than $200 million during the housing boom, warned that they would fight in court if they were left with peanuts and the city’s $29 million-a-year contribution to CalPERS was left intact.

Ultimately, most bond creditors settled with the city for upward of 50 cents on the dollar. The exception was Franklin, which is being offered about 10 cents on the dollar.

The San Mateo investment firm forced a lengthy trial, complaining that CalPERS was getting a free pass at Franklin’s expense.

“The bankruptcy code affords no preferential or exalted position” for pension liabilities, Franklin’s lawyers said in a recent court filing.

City officials defend their decision to hold CalPERS harmless, saying workers have already endured their fair share of pain in the Stockton bankruptcy. Employees have already suffered massive layoffs, while retirees have had their city-paid health insurance stripped away entirely. They say the mass resignations that would result if the CalPERS pensions were reduced would create chaos.

In Detroit, a bankruptcy judge has already ruled that the city had the right to scale back pension benefits. Employees and retirees have agreed to take modest pension cuts.

CalPERS, however, said the Detroit case is meaningless because California public pensions are safeguarded by the state constitution, a level of protection not present in Detroit.

Separately, CalPERS has tentatively settled with California’s other bankrupt city, San Bernardino, which had been threatening to seek a reduction in pension payments. Details of the settlement haven’t yet been disclosed.