WASHINGTON — The Supreme Court dealt a major blow on Wednesday to organized labor. By a 5-to-4 vote, with the more conservative justices in the majority, the court ruled that government workers who choose not to join unions may not be required to help pay for collective bargaining.

Forcing those workers to finance union activity violated the First Amendment, Justice Samuel A. Alito Jr. wrote for the majority. “We conclude that this arrangement violates the free speech rights of nonmembers by compelling them to subsidize private speech on matters of substantial public concern,” he wrote.

The ruling means that public-sector unions across the nation, already under political pressure, could lose tens of millions of dollars and see their effectiveness diminished.

“We recognize that the loss of payments from nonmembers may cause unions to experience unpleasant transition costs in the short term, and may require unions to make adjustments in order to attract and retain members,” Justice Alito wrote. “But we must weigh these disadvantages against the considerable windfall that unions have received” over the years.