Correction: An earlier version of this article included different ages for Huy Pham, a building technician who plunged to his death from the roof of the Costa Mesa, Calif., City Hall. Pham was 29. This version has been corrected.

Nearly half the city workers in Costa Mesa received layoff notices last week. Street sweepers. Firefighters. Mechanics. Payroll clerks. Animal control workers. In all, about 210 of the city’s 472 employees, many of whom have worked there for decades. On Thursday, as the notices were being handed out, one maintenance worker committed suicide by jumping from the city hall roof.

“It’s like they decided to blow up the city,” said Billy Folsom, 58, a mechanic who got a pink slip. “It’s devastating.”

The cutbacks are necessary because the escalating costs of providing pensions for police, firefighters and other unionized employees are draining the city’s revenue, city leaders say.

Within three years, city projections show, more than one of every five tax dollars will be spent on employees’ retirement benefits, which were made far more generous in the years before the stock market crashed in 2008.

“Just do the math — this is unsustainable,” said Jim Righeimer, the city’s recently elected mayor pro tem. He campaigned on the pension issue, eliciting anger and a counter-campaign from the city’s police and firefighters. “Under these kinds of burdens, we can’t do everything the city needs to do.”

The public pension fight

The financial follies of the boom years — by banks that lent too easily, by home buyers who bought places they couldn’t afford, by consumers who didn’t save — became obvious shortly after the recession.

But many states and cities may have overextended themselves as well, and the risks they undertook are now playing out in the public pension shortfalls provoking political battles across the nation.

Republican efforts to roll back public employee benefits and bargaining rights has triggered mass protests in places such as Wisconsin, Indiana and Ohio. But in Costa Mesa, where conservatives dominate city politics, the offensive against public worker compensation has gone further.

During the boom, many state and local governments promised their employees better pensions. Some employees were allowed to retire earlier. Others received a larger portion of their final pay. Financially, it was easy to do; the stock market was soaring, lifting pension fund balances.

Between 1998 and 2008, the last year for which figures are available, total pension payments by state and local governments rose twice as fast as their payrolls, according to census figures.

But now that the recession has led to steep drops in pension funds, those promises to past and present employees may be much harder to keep. Dozens of state and local pension funds around the country are now considered seriously underfunded. By 2009, about 58 percent of state and local pension funds were less than 80 percent funded, a standard benchmark of pension soundness, according to the Center for Retirement Research at Boston College.

The shortfalls have had far-reaching political ramifications. Already, some politicians ideologically opposed to public employee unions have attributed the problems to their greed and political influence. Now members of those unions are on the defensive.

“What angers a lot of us is that we’re being blamed for the economic situation,” said Jason Pyle, 38, a fire department captain who earned $160,000 in base, overtime and certification pay in 2010, according to city records. Pyle, who has been with the department for 14 years, could retire at age 54 with 90 percent of his base salary and some other forms of pay. “They’re marginalizing what we actually do — like everything I’ve done in my life now has no meaning.”

He called the city’s approach to the problem — the layoff notices — “a scorched-earth policy.”

Indeed, in few places has the rhetoric over the unions and the “ticking pension bomb” been as strident as it is in California — or, more specifically, this coastal bastion of conservatism where the battle erupted most clearly during Righeimer’s fall campaign.

Righeimer, 52, an Orange County developer, has long fought against unions. In the mid-1990s, after forming a political action group, he ran afoul of teachers unions while pushing for vouchers and a back-to-basics approach to education. Then, in 1997, he pushed a ballot measure to prohibit labor unions from using their members’ dues for political purposes without the permission of each member, each year.

Not surprisingly, when he declared his intention to run for City Council in this city of 116,000, he blamed the city’s budget shortfalls on the union-negotiated compensation for police, firefighters and other city employees.

In his view, governments have been too generous with public employee unions that have wide influence over local elections.

First, he and other critics note, the unions can be a major source of funding in local races. Righeimer’s campaign spent $70,000 for the November election, according to city records; the Costa Mesa police and fire unions, meanwhile, spent $101,000 in a campaign to discredit him. (Righeimer won the post of mayor pro tem, similar to a vice mayor.)

Second, he notes, many candidates compete to win the endorsement of police and firefighters.

“Everyone wants to get their endorsement,” he said. “They fight crime, save people’s lives, all these good things. The people really go for that.”

The unions note that their candidates have frequently lost. But when it comes to gaining richer pension benefits, they have often won.

After the state allowed richer pensions for many workers in 1999, many localities, including Costa Mesa, quickly followed suit. Today, police and firefighters in the city can retire at 50 with as much as 90 percent of their base salary and some other forms of pay. It was, in part, the tenor of the times, some said.

“After 9/11 happened, they were national heroes,” said Scott Baugh, chairman of the Republican Party of Orange County and a Righeimer ally. “Wouldn’t it be great to give a million dollars to every hero? It would be, but it is really unsustainable.”

Earlier this year, a bipartisan commission looking into pensions in California warned that “the retirement promises that elected officials made to public employees over the last decade are not affordable. . . . Pension costs will crush government.”

Pensions, by the numbers

According to city figures, for every dollar the city pays a police officer or firefighter, it must also set aside more than 40 cents to fund the employee’s pension. For every dollar paid a general employee, it must set aside 27 cents.

The average Costa Mesa police officer earned $105,000 in base overtime and certification pay in 2010, according to city records. The average firefighter earned $109,000 in base, overtime and certification pay last year.

City Council members say the rising costs of pensions compelled them to issue the layoff notices. The idea is to outsource many of the functions of city government to private firms or other governments. Firefighting, for example, could be contracted out to Orange County at a savings of millions of dollars. Private firms could take up payroll services and street sweeping. Police services are not currently slated for outsourcing.

Among those receiving pink slips Thursday was city building technician Huy Pham, 29. About an hour later, Pham plunged to his death from the top of the city’s Civic Center.

“We’re trying to understand the circumstances that led to it,” Lt. Bryan Glass said, according to the Associated Press. Relatives and others said Pham had not seemed suicidal anytime recently, the AP reported.

Although union leaders acknowledge the burden the rising costs of pensions has placed on the city, they note that they have offered to close the gap. Last year, the police and firefighters agreed to contribute 5 percent and 6 percent of their pay, respectively, to fund pensions. General employees agreed to raise their pension contributions by 4 percent.

“For three years we’ve given them every concession they’ve needed,” said Folsom, the city mechanic. He made $68,000 last year, according to city records. “We worked it out. This time, they’re just giving us the pink slips.”

Pyle, of the fire department, said the union was willing to make more concessions. He even called the City Council’s vote to raise pension benefits “a bad decision” because of its financial implications.

But the firefighters and police are angry, too, because they feel that their role in the city has been unfairly minimized by those seeking to restrict their compensation.

“If you agree to being spit on, bit, or have blood or fecal matter carrying the AIDS virus or hepatitis thrown at you, or have someone attempt to stab you with a knife or use your own sidearm to kill you, or simply run you down with a car, then the risk and dangers of a 30-year career in law enforcement justify an appropriate retirement,” said Jason Chamness, a police officer who earned $108,000 in base, overtime and certification pay last year and the president of the Costa Mesa police officers association.

But Righeimer says he is only asking the tough question.

“These are good, hardworking people, and to characterize them any differently is wrong,” Righeimer said. “The issue is . . . so how much?”