(Fortune Magazine) -- Even as the nation's economy is showing some tentative signs of bottoming out, another calamity looms: the public pension bomb.

For years, states nationwide have shortchanged the retirement programs that cover teachers, police, and other public employees; now the stock market plunge has wiped out billions of dollars from already underfunded plans. California, New York and Illinois are among the states scrambling to plug multibillion-dollar holes in their pension systems. The growing obligations raise the specter of higher taxes, diminished services, or even another round of costly federal bailouts.

"States have long needed to reduce their unfunded liabilities, and widespread investment losses have made it even more necessary to put money in," says Lance Weiss, author of a 2006 Deloitte study of state pensions. "But the market crash also means there's less money available to use for contributions. Everything is coming together to create a crisis."

To better understand this ticking time bomb it helps to focus on a single state, and New Jersey makes a compelling case study. For one thing, its situation is dire. In June 2008 the state estimated that the plan - one of the nation's largest, covering teachers, state employees, firefighters, and police - had $34 billion less than it needed to meet its obligations. Since then the market value of the plan has dropped from $82 billion to $56 billion (a new estimate of underfunding is due in July).

Also, New Jersey is in some ways ahead of the pack in trying to deal with the crisis - Gov. Jon Corzine, a Democrat, made addressing the problem a central theme of his 2005 campaign - and the obstacles it is encountering shed light on the hard choices facing other states.

"The pension obligations could spark a huge problem for New Jersey," says Thomas Kean, a former Republican governor. "They must be paid because they are absolutely an obligation of the state, but as it is, the budget is balanced with chewing gum and sealing wax."

***

To figure out how such a wealthy state (with a median household income of $65,933, New Jersey ranks No. 1) dug itself into this hole, set the clock back almost 20 years.

In 1990 the country was hit by a recession, and the new Democratic governor, James Florio, responded with a wildly unpopular $2.8 billion income and sales tax increase to balance the budget. Two years later, facing another budget shortfall, he turned to the state pension system for help. With almost unanimous support in the legislature, he pushed through the Pension Revaluation Act of 1992.

We'll spare you the minutiae of pension accounting and just say that the law permitted the state to recognize investment gains in the fund more quickly than under previous rules. It also lifted the projected rate of return on the fund's investments to 8.75% from 7% (since lowered to 8.25%). These "adjustments" had a big impact: According to an official Benefits Review Task Force report published in 2005, they allowed the state to cut its pension contributions by more than $1.5 billion in 1992 and 1993.

Republican Christine Todd Whitman, running on a tax-cutting platform, defeated Florio in the 1993 governor's race. To help pay for her promised tax cuts, Whitman, like her predecessor, turned to the pension fund. In 1994, at her urging, the legislature adopted another pension "reform" act that allowed her to reduce state and local contributions to the plan by nearly $1.5 billion in 1994 and 1995, according to the task force report. Florio's and Whitman's accounting changes were "the one-two punch from which the retirement system has never recovered," says Douglas Forrester, who was the assistant state treasurer under Kean.

***

Seeking to make up lost ground without putting up more money, the state's leaders looked to the magic of the stock market. In 1997 New Jersey sold $2.75 billion of bonds paying 7.6% interest, putting the proceeds into the pension fund to be invested for higher returns.

At that time Whitman said the ironically named Pension Security Plan would save taxpayers about $45 billion. It hasn't worked out that way. The fund has earned less than 6% annually since the bonds were issued.

"This is classically referred to as arbitrage," says U.S. Rep. Leonard Lance, a Republican who served in the New Jersey legislature from 1991 through 2008. "It's a questionable strategy in the private sector, and it's certainly not acceptable as a matter of public policy."

That wasn't the state's last venture into high finance. The system, along with almost every other investor, suffered sharp losses after the dotcom bust of 2001. Democrat James McGreevey, who became governor in 2002, hoped that professional money managers would improve the plan's returns. At the time New Jersey was the only state other than Texas to run its pension fund without outside help.

McGreevey appointed Orin Kramer, a money manager who had been finance chair of his unsuccessful 1997 gubernatorial campaign, as head of the State Investment Council, which sets policy for the pension plan. Kramer pushed the council to turn over some of the fund's assets to Wall Street professionals and to diversify into alternative investments such as hedge funds and private equity. But it took time for Kramer to devise a strategy and put it into action, so money didn't flow to alternative investments until 2006, on the eve of the bear market that would crush nearly all asset categories.

"Our asset-allocation model was based on the idea that there was no correlation between our alternatives and bonds and equities," says James Marketti, retired president of Communications Workers of America Local 1032, who has been a member of the state's investment council since September 2008. "It turns out they were perfectly correlated."

For all the miscues, New Jersey's pension woes can't be blamed on particularly poor investment results. An examination of state reports shows that the fund's returns have more or less tracked the broad stock market's. The real problem has been the underfunding.

Meanwhile, the obligations keep mounting: Even while they were neglecting pension contributions, New Jersey politicians were sweetening the pot. In 2001 benefits for the state's two largest groups of workers, government employees and teachers, were increased by 9%, creating an additional $4.2 billion in liabilities. In 1999 the state approved a "20 and out" measure that allowed firefighters and local police to collect pensions equal to 50% of their pay after 20 years of service - a perk previously available only to the state police. Benefits added since 1999 have increased liabilities by more than $6.8 billion, according to official estimates.

Today New Jersey seems locked in a downward spiral. "New Jersey and many other systems have negative cash flows, meaning that contributions are less than the benefits we pay out," says William Clark, director of the New Jersey Division of Investment, which manages the pension fund. "You can't make your money back when it's flowing out of the system."

***

Gov. Corzine's efforts to prop up the plan have had mixed results. After taking office he boosted contributions, injecting about $1 billion in 2007 and a similar amount in 2008. He planned to add another $1 billion in 2009, but in response to budget pressures now wants to spread that money over two years. And the legislature just passed a "pension holiday" bill that allows municipalities to skip their pension contributions for 2009.

Corzine has also imposed reduced benefits on state workers. Since 2007 he has raised the retirement age to 62, increased the salary requirement for pension eligibility, increased employee contributions, and capped pension income. But unions are fighting his request that members take unpaid furloughs and give up some or all of the wage hikes they are due.

"We believe reopening contracts should be a last resort as we seek to find other ways to free up money," says Anthony Miskowski, secretary of CWA Local 1033. "If we budge on the contracts, the unions are dead." But after a pause, he acknowledges that something has to give: "We'll be forced someday to be more flexible."

And those are baby steps compared with the sweeping measures recommended by consultants like Deloitte for all states facing pension crises. They include reducing benefits for current and future employees, pegging cost-of-living increases to actual inflation, cutting early-retirement programs, and forcing the states to stick with adequate funding plans. That's more of a wish list than a practical plan of action. "These are all politically sensitive solutions," says Deloitte's Weiss. "The unions are screaming, but states have to stop the bleeding."

If New Jersey reaches the point where one or more of the funds in its system runs out of money, the state will have to pay retirees out of annual revenue, adding another burden to the budget. That's how the state covers retiree health-care costs, expected to hit $1.1 billion this year. (An attempt to pre-fund those expenses began in the 1980s but was sacrificed to budget pressures in 1994.)

It would then have to slash services or boost taxes to balance the budget, a pair of ugly options. The Tax Foundation says New Jersey charges the highest state and local taxes in the country, the highest residential and commercial property taxes, and some of the highest sin taxes in the nation on cigarettes and alcohol.

If union concessions, cost cutting, and higher taxes are not enough, then what? Inevitably, New Jersey and other states would turn to Uncle Sam for help. The pressure on Congress would be great. "How will they say no to state workers when they've said yes to bankers?" asks Marketti.

Even so, Congress might balk at opening the door to a series of multibillion-dollar state bailouts. In that case, we might well see a wave of municipal or even state bankruptcies as pension obligations overwhelm local budgets. To Leonard Lance, the pension blowup is one more consequence of the financial recklessness that defined an era. "In so many areas there has been inappropriate spending," he says. "Now we all have to pay."

REPORTER ASSOCIATE Lawrence Delevingne contributed to this article.