The Supreme Court ruling on Wednesday that government workers can't be forced to contribute to labor unions that represent them in collective bargaining marked a major blow to public sector unions and put the future of organized labor in the United States in jeopardy.

The 5-4 decision in Janus vs. American Federation of State, County and Municipal Employees - which scrapped a 41-year-old decision that had allowed states to require public employees to pay some fees to unions that represent them - was immediately slammed by union leaders as a blow to working class Americans.

“In this case, a bare majority of the court, over the vigorous dissent of four justices, has conceded to the dark web of corporations and wealthy donors who wish to take away the freedoms of working people,” AFL-CIO President Richard Trumka said in a statement. “[I]t will further empower the corporate elites in their efforts to thwart the aspirations of millions of working people standing together for a better life.”

While union membership has been on the decline for decades, their power has remained strong in the public sector. Of the 16 percent of U.S. employees working in the public sector, more than one-third are still unionized – compared to just over six percent in the private sector, according to the Bureau of Labor Statistics.

Union leaders argued that so-called fair share fees pay for collective bargaining and other work the union does on behalf of all employees, not just its members. More than half the states already have right-to-work laws banning mandatory fees, but most members of public-employee unions are concentrated in states that don't, including California, New York, and Illinois.

The unions say the outcome could affect more than five million government workers in about two dozen states and the District of Columbia.

Labor leaders fear that not only will workers who don't belong to a union stop paying fees, but that some union members might decide to stop paying dues if they could, in essence, get the union's representation for free.

A recent study by Frank Manzo of the Illinois Public Policy Institute and Robert Bruno of the University of Illinois at Urbana-Champaign estimated that public-sector unions could lose more than 700,000 members over time as a result of the ruling and that unions also could suffer a loss of political influence that could depress wages as well.

Organized labor is a strong supporter of the Democratic Party and vehemently opposed President Trump’s nomination last year of Justice Neil Gorsuch, who was a deciding factor in Wednesday’s ruling.

As expected, the Supreme Court ruling drew a strong rebuke from Democratic lawmakers across the country.

“The Court’s decision today undermines the basic American premise, held up by courts for more than four decades, that if a union represents all employees in negotiating and administering a collective bargaining agreement, then all employees ought to share the costs of that representation,” Sen. Kamala Harris, D-Calif., said in a press release.

The ruling, however, fulfills a longtime wish of Trump and conservatives to do away with the fair share fees non-members pay to unions in 22 states as the court stated that the laws violated the First Amendment by compelling workers to support unions with which they may disagree.

“Great news today for America’s public servants, like teachers, police officers, and firefighters, who will no longer be forced to join a union or political organization and financially support leadership they disagree with,” House Majority Whip Steve Scalise, R-La., tweeted on Wednesday. “This is a victory for free speech!”

Despite the concern about the decline of their membership and their political clout, experts on organized labor say that in the long run the Supreme Court’s ruling will not be as damning a factor for unions as some make it out to be.

Daniel DiSalvo, a senior fellow at the Manhattan Institute, noted that doing away with fair share fees will cut into union coffers, but that union leaders will adapt and find other ways to fund their initiatives.

“It’s not a nail in the coffin for these unions,” DiSalvo told Fox News, noting that only a few states like new York and California with large public sector unions will feel the brunt of ruling. “They’ll still be big and they’ll still be powerful. Overnight the public unions in these states are not going anywhere.”

The Associated Press contributed reporting to this piece.