The Supreme Court on Wednesday issued a decision that is widely seen as a blow to public unions and could have particularly dramatic effects in New York City, where the United Federation of Teachers counts more than 100,000 members.

The 5-4 decision means that public unions in more than 20 states can no longer collect “agency fees” from non-members. Sometimes called a “fair share” fee, it is meant to help unions cover the cost of negotiating contracts that cover all workers, regardless of whether they are union members.

Now that employees have a financial incentive to opt-out of their unions, the decision is expected to drain membership, and with it, money that has helped fuel labor’s political clout.

The impact will likely be magnified for the UFT, the largest union local in the country. UFT President Michael Mulgrew was defiant, calling the Supreme Court “perverted and twisted” by political interests.

“As I promised my mother numerous times, I will pray for all of them when they’re burning in hell,” he said.

The decision was hardly a surprise: Justices had deadlocked on a similar case in 2016 after the sudden death of Justice Antonin Scalia. With Neil Gorsuch now on the bench, observers expected a conservative-leaning court to side with Mark Janus, an Illinois public employee who challenged the fee on the grounds that it essentially forced him to support a political organization and violated his right to free speech.

Elected officials across the labor-friendly state were quick to show their support Wednesday. Flanked by union leaders in New York City, Gov. Andrew Cuomo signed an executive order that exempts the personal information of state employees from public disclosure, saying anti-union forces in other places have used lists of addresses and phone numbers to “harass” public employees into leaving their unions. Mayor Bill de Blasio, meanwhile, joined more than 20 mayors from around the country in signing a symbolic pledge to protect workers rights.

“We believe working people deserve fairness. It’s clear that the conservative Supreme Court justices don’t share that same sentiment,” de Blasio said in an emailed statement.

The UFT relies on dues and agency fees for about 85 percent of its $185 million budget, according to federal documents. Currently, about 1,200 educators opt out of the UFT and pay agency fees instead. Union officials said those people can stop paying all fees immediately — which translates to a financial hit of about $1.5 million annually.

Members have an extremely short window to decide whether to stop paying dues for the upcoming year: Though educators can drop their membership at any time, the dues obligation can only be cancelled between June 15 and June 30 every year — giving members a chance to act on the court’s decision immediately.

With the Supreme Court decision, the number of members dropping their union is only expected to grow. That is what happened in states like Michigan, where membership in the state teachers union dropped by 20 percent after “right to work” laws outlawed mandatory agency fees.

The Janus decision cuts particularly deep because, writing for the majority, Justice Samuel Alito emphasized that employees must opt in to union membership. In New York City, union officials said teachers automatically become agency-fee payers, but they must opt-in to the union by signing a membership card.

Nat Malkus, deputy director of education policy at the conservative-leaning American Enterprise Institute, said the opt-in requirement could have an “enormous” impact on membership numbers.

“With the requirement for affirmative consent, any declines that were anticipated before Janus are likely lowball estimates,” he said. “The opt-in, opt-out difference can be just unbelievable.”

In anticipation of the Janus ruling, New York lawmakers recently passed legislation to help stem the potential losses and give members an incentive to keep their union cards.  The law gives union representatives time to meet with new employees, and allows unions to pull back services to non-members.

Under the law, UFT officials said the union is not obligated to provide a lawyer to non-members who face disciplinary charges, and that the UFT can limit services such as teacher trainings to only dues-paying members.

Dues are about $117 a month for teachers, while social workers, paraprofessionals, and members in other school jobs pay different amounts. Members also have the option of  contributing to a separate political fund, which the UFT uses to lobby lawmakers and support union-friendly candidates.

Many educators took to Twitter to show support for their union, using hashtags like #UnionProud.

“I know how important it is to have the UFT benefits as a way of protection,” wrote Lisa Ringston, a 20-year veteran of the education department who currently works with children who have autism. “With what little dues we pay, it goes a long way, and taking it away would be very detrimental.

Wednesday’s decision comes less than a week after a huge victory for the UFT — striking a deal with New York City to provide paid family leave to teachers. The union had been pressuring the city on the issue for months, and securing that victory could help demonstrate the UFT’s worth at a time when attracting dues-paying members could become more difficult.

The union took up the cause after a petition launched by two teachers went viral. Some say the Supreme Court decision is another opportunity for the union to become more responsive to its rank-and-file.

“Unions will need to better connect with their members,” said Evan Stone, co-founder of the advocacy group Educators for Excellence. “In light of this ruling teachers need to recommit to their unions, and unions need to recommit to their members by becoming even more democratic, diverse, and student-focused.”

Even before the decision was rendered, the UFT took on an aggressive campaign to hold on to members — who are now free to choose whether to keep supporting the union financially. But they are bracing for potential losses. Leaders have reportedly already considered downsizing their operations.

Mulgrew said the union will continue a recruitment and information campaign that started last winter. Along with local legislation to protect workers, he said that one-on-one conversations with teachers will be key in retaining membership.

“Having that conversation and building more active chapters at every work site has been the main push,” he said.

Daniel Lund Holstein, a high school math teacher, volunteered to knock on hundreds of doors of fellow union members to convince them to continue paying dues. He said the looming decision added to a feeling that many teachers have of being under attack, and inspired most to double-down and show support.

“The majority of teachers I talk to are very savvy about what exactly they get for those dues — and it is extensive,” he said. “When you have a bunch of teachers in the room or you have a one-on-one conversation, you have a lot of excitement about a revitalized union.”

If you’re an educator, let us know how the decision will affect your decisions about union membership.

Read more about potential impact on New York City here. And read about what has happened to schools, teachers, and students in other states after union protections were weakened.