FRESNO, Calif. -- Stockton, the California city with the nation's second-highest foreclosure rate, is facing a moment of decision on whether to become the biggest city to file for bankruptcy, as a deadline for talks between the city and its creditors approached late Monday.

City officials are still hoping to reach a deal that would restructure millions of dollars of debt under a new state mediation law designed to help municipalities avoid bankruptcy, City Manager Bob Deis said.

On some nights, negotiations with the 18 creditors have stretched past midnight and remain confidential. But Deis said that to avoid bankruptcy, any deal would have to result in sufficient savings to make the city solvent.

Meantime, officials have made preparations in case mediation efforts fail. The Stockton City Council is scheduled to decide Tuesday whether to adopt a special budget, which would cover the city's projected $26 million deficit in case of a bankruptcy declaration.

California cities are required by law to adopt a balanced budget by July 1 of each year.

If mediation fails and council members adopt the special budget, Stockton's lawyers could file for Chapter 9 protection in court as early as Wednesday, Deis said.

City officials say this river port city of 290,000 in the Central Valley has run out of options. In recent years, thousands of new homes mushroomed in Stockton, part of a suburban housing boom that attracted buyers from the San Francisco Bay area and beyond.

When the economy crashed and the construction bubble burst, Stockton was battered by foreclosures and lost income from property taxes and other fees.

Multi-year labor contracts for city workers with escalating costs and generous retirement plans added to the burden. And expensive city investments – a promenade, a sports arena and a hotel – failed to produce an economic boon.

The city also has one of the highest crime and unemployment rates. It has twice topped Forbes magazine's list of "America's most miserable cities."

In the past three years, officials addressed $90 million in deficits through a series of drastic cuts. They eliminated one-fourth of the police officers, one-third of the fire staff and 40 percent of all other employees. They also cut wages and medical benefits.

To plug next year's $26 million budget hole, the proposed budget suspends debt payments and payments for legal claims; reduces payments for retiree medical benefits; further reduces some pay and benefits and increases revenue through code enforcement and parking citations.

The proposed budget includes no major service reductions, Deis said.

"The whole purpose of filing Chapter 9 is to avoid an uncontrolled chaotic situation," he said. "Bankruptcy provides the equivalent of a pause button. It retains services and provides structure so you don't have a bunch of lawsuits."

If the city files for bankruptcy, it will still have to work out a court agreement with creditors on how to pay them upon exiting bankruptcy.

Stockton was the first city to test the new state mediation law, Assembly Bill 506, which is less than six months old. Under the law, municipalities considering bankruptcy must first negotiate behind closed doors with creditors for up to three months, with the goal of settling debts without filing for Chapter 9 protection.

If the city is able to reach a deal through mediation, Deis said, city council members could modify Tuesday's special budget to reflect the deal, or they could adopt the budget and come back in July to modify it.

Officials say they are optimistic, even if they decide to file for bankruptcy. They point to Vallejo, a smaller California city which filed for Ch. 9 protection in 2008 and emerged from bankruptcy last year.

"Vallejo is leaner, smarter and they've got the confidence of their citizenry," Deis said. "I think Stockton will be doing the same."