LOS ANGELES—California has long been a union stronghold, but voters in the reliably Democratic state are gradually taking a more negative view of organized labor, a poll released Friday suggested.

The independent Field Poll said that by a narrow margin, more voters said unions do more harm than good, as opposed to those who see organized labor as generally beneficial.

The figures represent a turnaround from a 2011 Field survey, when more voters said unions resulted in more good than harm.

The shift comes at a time of ongoing labor conflicts in the state and nation, often involving government employee pensions and retirement benefits. It also tracks a long-running national trend, in which support for labor unions has gradually slipped.

Retirement costs for government workers contributed to bankruptcies in three California cities in recent years—Stockton, Vallejo and San Bernardino—and municipal budgets have been squeezed by growing worker benefits and pay. In the San Francisco Bay Area, two transit strikes this year caused headaches for hundreds of thousands of commuters.

In many communities "public pensions are starting to crowd out the services that local governments can provide. That doesn't sit well with the public," pollster Mark DiCamillo said.

Compared to the earlier poll, unions lost ground across most age, political and demographic groups.

Since 2011 "virtually every voter subgroup now displays a shift toward a somewhat more negative view of labor unions than they had expressed previously," the survey said.

The poll of 1,002 registered voters, conducted Nov. 14 to Dec. 5, found that 45 percent said labor unions do "more harm than good."

That compared to 40 percent who said unions do "more good than harm."

The findings were nearly identical when voters were asked about labor unions, generally, or public employee unions.

California Labor Federation spokesman Steve Smith said the figures show the results of a well-funded, coordinated attack on unions by corporate interests that want to abolish organized labor.

He agreed that the San Francisco transit strikes and ongoing disputes over the cost and size of pensions had some impact in shifting public views, but added that the public often overlooks the positive work union members do, including helping low-wage workers and pushing for a higher minimum wage.

"Year to year, poll to poll, these numbers fluctuate," he said. "We've got to continue to fight those fights, and fight those fights in a very visible way."

"Without a labor movement, the middle class will disappear," Smith added.

According to the poll, those viewing unions more negatively increased 10 percentage points from March 2011, while the percentage of those viewing unions as more beneficial dropped 6 points during the period.

Democrats, who hold every statewide office and control both chambers in the Legislature, have long had close ties to unions. But the survey found 30 percent of registered Democrats now say unions do more harm than good, up from 21 percent in the 2011 survey.

More than half of whites, 51 percent, say unions do more harm than good, up from 39 percent in 2011. Even in households with a union member, 31 percent said unions do more harm than good, up from 18 percent in 2011.

Los Angeles, the state's largest city, has struggled to keep growing worker retirement costs from eating into the budget for tree trimming, libraries and street repairs. Last year, voters in San Diego and San Jose overwhelmingly approved cuts to retirement benefits for city workers.

Several California mayors want voters to consider an initiative on next year's ballot that would amend the state Constitution to allow local governments to negotiate changes in pension benefits for current and future employees.

Last year, labor groups and other Democratic interests funneled at least $75 million into their drive to defeat Proposition 32, which would have starved unions of the tens of millions of dollars they use to finance campaigns and political organizing.

The survey had a margin of error of plus or minus 3.2 percentage points.