WASHINGTON (AP) - The Supreme Court ruled Wednesday that government workers can't be forced to contribute to labor unions that represent them in collective bargaining, dealing a serious financial blow to organized labor.



The justices are scrapping a 41-year-old decision that had allowed states to require that public employees pay some fees to unions that represent them, even if the workers choose not to join.



The 5-4 decision fulfills a longtime wish of conservatives to get rid of the so-called fair share fees that non-members pay to unions in roughly two dozen states. The court ruled that the laws violate the First Amendment by compelling workers to support unions they may disagree with.



"States and public-sector unions may no longer extract agency fees from nonconsenting employees," Justice Samuel Alito said in his majority opinion for the court's five conservative justices.



President Donald Trump weighed in minutes after the decision was handed down, while Alito still was reading a summary of it from the bench.



"Big loss for the coffers of the Democrats!" Trump said in a tweet.



In dissent, Justice Elena Kagan wrote of the big impact of the decision. "There is no sugarcoating today's opinion. The majority overthrows a decision entrenched in this Nation's law - and its economic life - for over 40 years. As a result, it prevents the American people, acting through their state and local officials, from making important choices about workplace governance. And it does so by weaponizing the First Amendment, in a way that unleashes judges, now and in the future, to intervene in economic and regulatory policy."



The court's three other liberal justices joined the dissent.



The court split 4-4 the last time it considered the issue in 2016 following the death of Justice Antonin Scalia. Organized labor is a big supporter of Democratic candidates and interests. Last year, unions strongly opposed Justice Neil Gorsuch's nomination by Trump. Gorsuch was in the majority on Wednesday.



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



The case involving Illinois state government worker Mark Janus is similar to the one the justices took up in 2016. At that time, the court appeared to be ready to overrule a 1997 high court decision that serves as the legal foundation for the fair share fees. But Scalia's death left the court tied, and a lower court ruling in favor of the fees remained in place.



The unions 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.



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.

Copyright 2018 The Associated Press