Pennsylvania's public-sector labor unions, which represent 6 percent of the state's workers and spend tens of millions of dollars on political campaigns annually, could be substantially handicapped by a blockbuster decision by the U.S. Supreme Court.

The nation's highest court on Wednesday ruled, 5-4, that government employees who decline to join unions are not required to pay "fair share" fees to the labor groups that collectively bargain on their behalf. Republicans and conservative donors such as the Koch brothers long sought the policy, hoping to cripple their opposition.

"Big loss for the coffers of the Democrats!" tweeted President Trump.

The case stemmed from Mark Janus, a child support specialist in Illinois, who challenged the American Federation of State, County and Municipal Employees in a federal lawsuit over the $45 in monthly fees he had to pay to the union despite not being a member. His lawyer argued the state violated workers' First Amendment rights by making them contribute to groups that participate in political activity they may not support.

Supreme Court Justice Samuel A. Alito Jr.'s majority opinion in the case said that forcing nonunion members to pay the fees amounted to "unconstitutional exactions." Justice Elana Kagan, writing the dissent, cited a 1977 court precedent that found the fees did not abridge free speech because they "could not go to any of the union's political or ideological activities."

The court's ruling effectively makes the nation a "right-to-work" zone for public-sector unions. It means unionized government workers looking for a temporary boost in their paychecks may leave the organizations. The Democratic Party also might lose crucial campaign dollars from one of its most reliable institutional donors.

Or, some labor leaders said, unions could stay strong — and perhaps even grow more powerful.

Pete Matthews, president of Philadelphia's AFSCME District Council 33, said his blue-collar municipal union spent more than a year asking members to sign cards pledging to remain. He said he doubted the ruling would cause many members to flee.

But, he said, the Supreme Court's ruling could mean that D.C. 33 gives less money to candidates. If labor groups need to spend more time recruiting and retaining members, that leaves fewer hours in the day for politics.

"I'm quite sure it would have an impact," he said.

Any fallout is likely to be felt most in the 2020 presidential election, political analysts said.

Janus ruling follows years of labor losses

The Supreme Court's decision comes after America's unions have suffered decades of decline. At their peak in the mid-1950s, one-third of workers were members of a union. In recent years, public-sector unions have represented a larger percentage of workers than private-sector ones — making this ruling even more significant for the future of organized labor.

Gabe Morgan, vice president of Service Employees International Union 32BJ, said the "vast majority" of his union's members have signed cards promising to stay on as members and otherwise pledged their continued support. His group represents workers in city governments and school districts in Pennsylvania, as well as those in the private sector.

While conservatives painted the Janus decision as a "once-in-a-lifetime opportunity to end the Democratic Party" and unions, Morgan said, he doesn't believe that will come to pass. To the contrary, he thinks their plans could backfire as workers feel increasingly under siege.

"They've now gone so far in these attacks," he said. "We've seen our members, even Republican members, even Trump supporters, who are actually sending more money to the union PAC fund because they don't want to see unions go away."

According to a 2017 Gallup poll, labor unions are more popular among Americans now than at any point in the last 14 years. Sixty-one percent of adults surveyed said they support unions. An analysis by the left-leaning Economic Policy Institute found that unions saw a boost in membership in 2017 of 262,000 people, three-quarters of whom were under 35.

Republican officials and conservative activists hailed the ruling. Charles Mitchell, CEO of the Commonwealth Foundation, called it "a huge victory" for Pennsylvania's government workers that "heralds a seismic shift in the landscape of public-sector labor law in Pennsylvania and across the country."

Scott Wagner, Pennsylvania's GOP gubernatorial nominee, has fought for legislation that would eliminate the prevailing wage for state-funded projects and make it unlawful for public employers to automatically deduct political contributions from workers' paychecks. "With this precedent now in place," he said, "I will be able to make the necessary reforms to ensure that more Pennsylvanians can find jobs."

Democratic Gov. Wolf said the "court's decision is a major step backward for working families and the middle class."

Private-sector unions, other workers could be targeted next

U.S. Sen. Bob Casey, a Pennsylvania Democrat, warned on Monday that an anti-labor ruling precedent might not be limited to unions representing government workers.

"Even if we didn't have union participation in supporting candidates, I think there are some members of the corporate right that just don't want workers to be organized anyway," he said.

Ryan Boyer, leader of the Laborers' District Council in Philadelphia, agreed with Casey that the next attempted "strike" by anti-labor forces could be against members of private-sector unions. His union mostly represents workers outside of the government.

"Now it's pretty transparent — the right's movement against working people," he said. "We're going to band together and fight harder than in the past."

Public-sector unions also are a major force in New Jersey. For example, from 1999 to 2014, the New Jersey Education Association spent $57 million on lobbying, campaign contributions, and independent political expenditures — twice as much as any other special interest group, according to the state election commission.

How right-to-work laws have handicapped unions, Democrats

Are labor leaders who are expressing optimism after the ruling whistling past the graveyard? According to a 2014 report by the Congressional Research Service, 5.6 percent of workers are union members in states with "right-to-work" laws, compared with 15 percent in other states.

Another study found that "right-to-work laws reduce Democratic presidential vote shares by 3.5 percentage points." The researchers discovered "similar effects" in U.S. Senate, House and state races.

Such laws prohibit unions from collecting dues from nonmembers in a workplace, even if they represent all employees there.

Pat Eiding, president of the Philadelphia AFL-CIO, said some unions have proven resilient, noting that right-to-work Michigan added 52,000 new union members last year.

"Sometimes waking up the sleeping dog is not what the right wing expected it to be," he said.

About 297,000 Pennsylvania public-sector workers belonged to a union in 2017, according to an online database maintained by economics professors Barry Hirsch and David Macpherson. Roughly 33,000 were represented by a union, but not members. Black women made up the largest share of government employees, followed by white women.

Altogether, 12 percent of the Pennsylvania workforce — 665,000 public and private employees — was unionized in 2017, per the U.S. Bureau of Labor Statistics.

Ted Kirsch, president of the American Federation of Teachers in Pennsylvania, said his union had been anticipating a negative ruling and has encouraged locals to get its 35,000 members to "recommit to the union" by signing cards. Fewer than 10 percent of the people represented by the union are not members, Kirsch said.

He blames political gamesmanship. Senate Republicans blocked President Barack Obama's choice for a Supreme Court vacancy in 2016, allowing President Trump to nominate conservative Justice Neil Gorsuch.

"With Gorsuch in there, we're losing. It's politics. They want to destroy the unions," said Kirsch, who predicts some dropoff in union participation but sees many members as more motivated. "It's an attack on them and their jobs."

John McNesby, president of Lodge 5 of the Fraternal Order of Police, said his union of 7,500 members represents fewer than 10 people who have not joined. His strategy for member retention is to emphasize the service his union provides. He also thinks new Philadelphia District Attorney Larry Krasner, who has clashed with police officers and their union, may inadvertently help.

"Our members know what they get for their dues money," McNesby said. "I think we'll be OK."

Staff writer Andrew Seidman contributed to this article.