This has been a difficult year for government workers across the country, who are fighting uphill battles to hang on to their pensions and stable salaries — and it’s not over yet.

From California to Pennsylvania, workers are facing efforts to sharply curtail the job security and benefits they have enjoyed for years, perks long viewed as compensation for the sometimes lower salaries in the public sector.

Now, the perks that came with being a firefighter or a teacher have become a target, not only for conservative lawmakers but for Democrats under pressure to make deep cuts in government budgets.

Experts note a decline in public support for government workers and their powerful unions, a sentiment shared by conservative activists eager to weaken organized labor. And never have they been more confident than this week, when Wisconsin Gov. Scott Walker (R) fended off a recall attempt orchestrated largely by unions outraged at his efforts to end collective bargaining for most public employees and teachers.

“We absolutely intend to use this going forward,” said Brendan Steinhauser, spokesman for FreedomWorks, a tea party organization that has been working to undercut public employee unions’ power through state legislatures. The group views the failed attempt to unseat Walker as a powerful motivator for other Republican governors.

The message, Steinhauser said, is: “Be bold, be a leader, be a conservative and you’ll be rewarded.”

Wisconsin is one of several places where public employees have become targets this year. San Diego and San Jose residents voted overwhelmingly Tuesday to cut pension benefits for city workers. The votes followed dramatic steps to curb union power in Indiana and Louisiana, and efforts by some in Congress to freeze salaries and whittle away benefits for federal workers.

Lawmakers in Pennsylvania and elsewhere are considering legislation that would weaken teachers unions. And some conservatives plan to push Republican leaders in Michigan, where lawmakers have had limited success curbing union power, to redouble their efforts in the wake of Walker’s victory next door.

Public workers have also borne much of the brunt of job cutting in recent years. Since June 2008, state and local governments have shed more than 500,000 jobs. And while the private sector has experienced some recovery, public sector job losses continue to mount.

Karen McDonough, who has worked in the city of San Jose’s environmental services department for two decades, said before Tuesday’s vote she tried to change voters’ minds by telling them her version of the story: that she is a hardworking senior employee who had gone years without a pay raise.

“The response I got the most was ‘I don’t get a pension. Why should you?’ ” McDonough said in an interview Thursday. “I tried to explain to them that [the pension] is part of our total compensation, that we don’t get stock options and bonuses. We’re just different. That is not something they’re interested in hearing anymore.”

Public employee unions, which became the heart of the labor movement with the decline of manufacturing unions, have lost the public relations battle, experts say. Once viewed as middle-class stalwarts who labor for the common good, government workers now are often seen as unwilling to make the same sacrifices as their counterparts in the private sector.

“I think that it’s the fault of the unions themselves for failing to recognize they are out of step with the public sympathies,” said Gary Chaison, a professor of labor relations at Clark University in Massachusetts. “There is a perception that, through their political influence, they are getting a special deal. They’re doing well while others are not.”

Union officials contend that the public is not aware of the sacrifices government employees have made. Federal workers’ pay rates, for example, have been frozen for the past two years — although raises for individuals are still allowed for promotions and some other reasons — and most new employees hired starting next year will contribute a greater proportion of their salary to retirement benefits.

On the state level, they say, public employees are being attacked and scapegoated by organized labor’s political foes. Some union officials agree that they are partly to blame for the unfriendly atmosphere — that over the years, as the percentage of Americans belonging to unions has declined, they have not done enough to convey the important role unions play in the community. But they also note that in many of the battles they’ve fought and lost — including the one in Wisconsin — they were vastly outspent by their opponents.

“It’s clearly going to have some impact when you have the relentless attacks like we’ve seen,” said Steve Smith, a spokesman for the California Labor Federation. “But at the end of the day these are firefighters, teachers, police officers, neighbors, local heroes.”

In San Diego and San Jose, voters overwhelmingly supported measures to reduce pension plans for city employees. In San Jose, with the Democratic mayor’s support, 70 percent of voters backed the plan. Proponents said the measures would bring their pensions in line with private industry.

That tide has swept the country, led by Republican governors. This year, Gov. Mitch Daniels signed a bill establishing Indiana as the nation’s 23rd “right to work” state, which prevents unions from charging nonunion workers mandatory dues. In Louisiana, Gov. Bobby Jindal pushed through a series of bills targeting teacher tenure and salaries. The next battle may unfold in Michigan, where union backers are vowing to enshrine collective-bargaining in the state constitution.

Some Democratic leaders also have been butting heads with their public employee unions. Chicago Mayor Rahm Emanuel has called for a suspension of the automatic cost-of-living increases granted to retirees, and Illinois Gov. Pat Quinn is seeking to cut the pensions of current state workers.

In Pennsylvania, advocates of school vouchers are fighting a pitched battle with teachers unions. The conservative activists behind the push say it is a two-pronged effort to bring about a policy change while delivering a blow to the unions.

Polling analyst Scott Clement contributed to this story.