After becoming the largest city in America to declare bankruptcy in 2008, Vallejo, Calif., began to reinvent itself. (David Paul Morris/BLOOMBERG)

The first couple of years were ugly. After this working-class port city became the largest in America to declare bankruptcy in 2008, crime and prostitution surged as the police force was thinned by 40 percent. Firehouses were shuttered, and funding for libraries and senior centers was slashed. Foreclosures multiplied and home prices plummeted.

But then this city of 116,000 began to reinvent itself. It started using technology to fill personnel gaps, rallying residents to volunteer to provide public services and offering local voters the chance to decide how money would be spent — in return for an increase in the sales tax. For the first time in five years, the city expects to have enough money to do such things as fill potholes, clear weeds, trim trees and repair tennis courts.

The nation’s cities are weak links in the U.S. economy and, if they collapse in large numbers, it could knock the country’s recovery off course. Cuts at the federal level are being pushed down to the states, which in turn are passing the problems to their cities.

The strains are especially great in California, which was at the epicenter of the housing market meltdown and the deep recession that followed. Even before revenue slowed, the state was facing unique constraints on public finances because its laws make it difficult to raise taxes.

The dire conditions, however, have made California a laboratory for how to run cities in an age of austerity.

Declaring bankruptcy used to be a last resort for cities, not only because it would cripple their ability to borrow for years to come but because of the blow to their reputation. But that attitude has started to change as more cities have found themselves facing fiscal catastrophe; bankruptcy offers an opportunity to start over with a clean slate.

At least three California cities — Stockton, Mammoth Lakes and Montebello — have declared that they are exploring the option. And at least 100 of the state’s 482 cities are on track to face a similar predicament by the end of the year, according to Barbara O’Connor, a professor at California State University at Sacramento.

Chris McKenzie, executive director of the League of California Cities, said that “no one expected the downturn to last this long,” adding: “After years of struggling to keep things together as best they could, cities are getting closer and closer to the edge.”

Economists warn that a number of large bankruptcies of cities, concentrated over a short period of time, could have a devastating effect on the national economy. Banking analyst Meredith Whitney in 2010 ominously predicted hundreds of billions of dollars in municipal bond defaults. While defaults on that scale haven’t happened — and Whitney’s critics came out in droves to attest to the health of the municipal bond market — the specter of such a crisis hasn’t disappeared.

City’s cash runs out

Vallejo, about 35 miles northeast of San Francisco, became the poster child for the failures of municipal budgeting in 2008 when its cash reserves dwindled to zero and it was unable to pay its bills amid falling property tax revenue and the soaring cost of employee compensation and pensions.

During happier times, Vallejo’s salaries for city employees had ballooned, with a number of top officials making $200,000 or $300,000. More than 80 percent of the municipal budget went toward compensation.

The city’s credit rating dropped to junk status, and as part of its bankruptcy settlement, Vallejo paid only five cents for every dollar it owed to bondholders. On the labor side, officials cut workers’ pay, health care and other benefits but left pensions intact.

For Vallejo to survive, two city council members — Marti Brown, 46, a redevelopment worker for the state, and Stephanie Gomes, 45, a legislative specialist for the U.S. Forest Service — decided that the city needed to study best practices from around the world and bring some of them to California.

“We’re trying to be more innovative and risk-taking,” Brown said. “It’s something we’ve been forced to do, but it’s turning out to be a really positive experience for the city.”

The police went high-tech, investing $500,000 in cameras across the city that allow officers to monitor a larger area than they could before. The department deputized citizens to participate in law enforcement by sharing tips on Facebook and Twitter.

Gomes, whose husband is a retired police officer, focused on public safety. The couple went neighborhood to neighborhood setting up e-mail groups and social media accounts so people can, for instance, share pictures of suspicious vehicles and other information. “There have been countless cases where ordinary people have stopped crimes this way,” Gomes said.

The number of neighborhood watch groups jumped from 15 to 350. Citizen volunteers came together monthly to paint over graffiti and do other cleanup work.

And the city council struck an unusual deal with residents — if they agreed to a one-penny sales tax increase, projected to generate an additional $9.5 million in revenue, they could vote on how the money would be used. The experiment in participatory budgeting, which began in April, is the first in a North American city.

The approach was pioneered in Port Alegre, Brazil, as a way to get citizens involved in bridging the large gap between the city’s middle-class residents and those living in slums on the outskirts. Individual districts in New York and Chicago are also experimenting with the process, and residents there have expressed interest in spending money on things such as more security cameras and lighting, public murals, and Meals on Wheels for seniors.

A statewide shortfall

As the 2012-13 budget season kicks off in California, Vallejo’s neighbors are looking at severe cuts, in part because of reduced support from the state. Gov. Jerry Brown (D) this month revealed that California is facing a crushing$16 billion deficit because of a shortfall in tax revenue. As a result, the state is diverting billions that had been earmarked for redevelopment or housing assistance away from cities that were already under fiscal stress.

Stockton is in eleventh-hour negotiations with creditors to try to avoid bankruptcy. The city of Hercules defaulted on a $2.4 million bond interest payment in February. Vacaville is considering closing City Hall every Friday and forcing employees to take unpaid leave or vacation time.

The state capital, Sacramento, which is expecting an $18 million deficit for fiscal 2012-13, has proposed cutting 286 full-time jobs, including police and firefighters, a move that would probably leave the city unable to respond to home burglaries and car accidents and lengthen the response time for 911 calls in all but the most dire cases.

Vallejo is in a markedly different situation. While it still faces some serious challenges — crime continues to be a problem, and the housing market remains depressed — the city’s finances are doing so well that a federal judge released it from bankruptcy in November.

“We’re seeing a lot of cities around us that are where we were five years ago,” Gomes said. “Some of those cities were laughing at us back then. It’s nice to be on the other side of it.”

While its general-fund budget of $69 million for 2012-13 is a far cry from the $85 million at its peak in the 1980s, Vallejo is in much better financial shape than many other cities around the country.

Assistant City Manager Craig Whittom, who has worked in Vallejo since 2003, said the bankruptcy may have been the best thing to happen: “It was effective at helping us re-create ourselves and change the culture so that we could restart from a stronger financial footing.”