Janus argued his $45 monthly fee to the American Federation of State, County and Municipal Employees was unconstitutional. He said that the fees infringed on his First Amendment rights, and that, in the case of public employees whose contract negotiations are with the government, the fees were a form of political advocacy.

Those fees, approved by the court in the 1977 case Abood v. Detroit Board of Education, cover collective bargaining costs, such as contract negotiations, but are meant to exclude political advocacy.

Janus, an employee at the Illinois Department of Healthcare and Family Services, asked the court last summer to overrule a 40-year-old Supreme Court decision. It found that public sector unions could require employees affected by their negotiations to pay so-called agency fees, which have also been called "fair share fees."

The case, one of the most hotly anticipated of the term, is the second in two days to hand a major victory to conservatives, following Tuesday's ruling by the high court that President Donald Trump's travel ban is constitutional. Some experts had said a finding in favor of the plaintiff, Mark Janus, would be the most significant court decision affecting collective bargaining in decades.

The Supreme Court ruled 5-4 on Wednesday in Janus v. AFSCME that nonunion workers cannot be forced to pay fees to public sector unions.

"Compelling individuals to mouth support for views they find objectionable violates that cardinal constitutional command, and in most contexts, any such effort would be universally condemned," wrote Justice Samuel Alito, who authored the court's opinion in the case.

Trump hailed the ruling immediately after it was handed down. In a post on Twitter, the president wrote the decision was a "loss for the coffers of the Democrats."

Supreme Court rules in favor of non-union workers who are now, as an example, able to support a candidate of his or her choice without having those who control the Union deciding for them. Big loss for the coffers of the Democrats!

The court dismissed the union's argument that agency fees prevented free-riding from employees who benefit from the union's negotiations. AFSCME argued that, because it was obligated by law to represent the interests of both union and nonunion members, the fees were a way for employees to pay their fair share for contact negotiations from which they benefited.

Avoiding free-riders, Alito wrote, "is not a compelling interest."

"Many private groups speak out with the objective of obtaining government action that will have the effect of benefiting nonmembers," he wrote. "May all those who are thought to benefit from such efforts be compelled to subsidize this speech?"

"There is no doubt that this decision profoundly impacts whether public sector unions will exist in the future," said Lauren Novak, a partner at the law firm Schiff Hardin who has represented both labor unions and employers. "Without the ability to collect fair share fees, many may not survive."

Labor activists and unions immediately decried the court's ruling.

“Today’s Supreme Court Janus decision is yet another effort to put obstacles in front of working men and women to join collectively behind the power of a unified voice," UAW President Gary Jones said in a statement Wednesday. "To be clear, labor will survive. But to be equally clear, our elections do matter, as the appointment of conservative Justice Neil Gorsuch by the Republican-led Senate left little doubt about the outcome of this decision. The Janus decision is just another barrier and another attack on working men and women."

The case is the third in five years on the question of fair share fees to come before the Supreme Court. In 2014, the question came to the high court in Harris v. Quinn, but the justices declined to answer the central question over agency fees' constitutionality, and instead ruled 5-4 that the petitioners in the case were not public employees.

In 2016, the court issued a one sentence opinion on Friedrichs v. California Teachers Association that left the question open.

In a harshly worded dissent, Justice Elena Kagan wrote that by overturning Abood, the court was improperly disrespecting established precedent. She wrote that the decision "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," Kagan wrote. Kagan's dissent was joined by the court's liberal justices, Ruth Bader Ginsburg, Stephen Breyer, and Sonia Sotomayor.

Correction: Mark Janus is an employee at the Illinois Department of Healthcare and Family Services. An earlier version misstated the department's name.