Stockton, California, can stay in bankruptcy after a judge said he found that the biggest U.S. city in bankruptcy negotiated in good faith with its creditors, and that the creditors didn’t.

Creditors, including Assured Guaranty Corp. and Franklin Resources Inc. had argued that Stockton didn’t qualify for bankruptcy because the city isn’t truly insolvent, and that its leaders didn’t negotiate a potential settlement in good faith.

Negotiation is a “two way street,” said U.S. Bankruptcy Judge Christopher M. Klein in Sacramento, addressing creditors who he said didn’t negotiate in good faith. “You cannot negotiate with a stone wall.”

In the course of the hearing today, Klein has also said that the city’s witnesses were credible and that the city was “by any measure” insolvent when it filed for protection from creditors.

The city of 296,000, an agricultural center about 80 miles (130 kilometers) east of San Francisco, is among three municipalities that have said they’ll try to force creditors, including bondholders, to take less than the principal they are owed. The other two are San Bernardino, California, and Jefferson County, Alabama. No city or county since at least the 1930s has used the power of a U.S. bankruptcy court to force a reduction in its debt principal.

Without bankruptcy court protection, Stockton’s creditors would be free to sue the city in state court, where it’s easier to force asset sales, cuts in city services or a boost in revenue to pay debt. While in bankruptcy, Stockton is shielded from such tactics and has more power to choose which bills to pay.

Before filing for bankruptcy in June under Chapter 9 of the U.S. Bankruptcy Code, the city asked bondholders and other lenders owed more than $300 million to take less than full repayment. The city listed assets of more than $1 billion and debt of more than $500 million in its bankruptcy petition.

Stockton joined cities across the U.S. using the federal bankruptcy code to get out from under billions of dollars in obligations they couldn’t afford following the longest recession since the 1930s. Stockton rode a surge in new-home construction in the 2000s that preceded the housing crash and a wave of foreclosures that sapped the city’s tax-revenue gains.

Creditors claimed that the city failed to meet at least one of three primary tests specified in Chapter 9 or California law. Before turning to bankruptcy, a city must be insolvent, have permission from its state government, and have tried in “good faith” to negotiate a deal with creditors.

Assured, based in Hamilton, Bermuda, argued in court papers that the city, in an effort to become insolvent, manipulated its budget process by refusing to raise taxes and limiting service cuts.

The insurer would be on the hook for tens of millions of dollars in bond payments if the city wins permission to eliminate the debt.

On the good faith test, Assured and the other bond insurer in the case, MBIA Inc. unit National Public Finance Guarantee Corp., claim the city wasn’t serious about striking a deal during months of pre-bankruptcy talks required by California law.

Franklin’s subsidiary, Franklin High Yield Municipal Fund, and Wells Fargo Bank NA filed court papers saying they support the objections of Assured and National Public Finance.

The city never held talks with the California Public Employees’ Retirement System, or Calpers, which provides retirement plans for city employees. The biggest U.S. public pension fund refused to negotiate with Stockton, claiming that under state law it isn’t authorized to reduce the city’s contributions to the fund. Klein said today that Stockton didn’t have an obligation to negotiate with Calpers.

The city is slated to stop paying for retiree health care on June 30 as part of a spending plan the City Council approved in June, citing a $417 million unfunded liability. The benefit had allowed workers employed as little as a month to receive city-paid health coverage for life, for both the employee and his or her spouse, Bob Deis, the city’s manager said.

Stockton’s unemployment rate was 18.7 percent in January, almost twice the state jobless rate of 9.8 percent, according to the California Employment Development Department. The national unemployment level that month was 7.9 percent, according to U.S. Labor Department data.

Born in the Gold Rush, Stockton struggled for decades, relying on tax revenue from farming and shipping at its deep- water port on the San Joaquin River. A housing boom in the early 2000s brought a surge in revenue as homebuyers, seeking refuge from soaring prices in San Francisco and Silicon Valley, flocked to Stockton, where starter homes cost around $400,000.

The city used the increase and issued debt to build a gleaming new arena and ballpark on its riverfront, and buy a new City Hall it later couldn’t afford to occupy.

Last year, the Stockton metropolitan area had the highest foreclosure rate in the U.S., affecting one in every 25 homes, or almost three times the national average, according to RealtyTrac Inc., an Irvine, California-based data provider.

In February 2012, Deis announced the city was on the verge of insolvency from mounting retiree costs, the recession and accounting errors that overstated revenue. A month later, the city began three months of talks with bondholders and labor unions that failed, prompting officials to seek bankruptcy.

The case is In re Stockton, 12-32118, U.S. Bankruptcy Court, Eastern District of California (Sacramento).