MADISON, Wis. (AP) — Wisconsin’s right-to-work law, championed by Republican Gov. Scott Walker as he was mounting his run for president, was struck down Friday as violating the state constitution.

Wisconsin Attorney General Brad Schimel, also a Republican, promised to appeal the decision and said he was confident it would not stand. Schimel has not made a decision on whether to seek an immediate suspension of the ruling while the appeal is pending, spokesman Johnny Koremenos said.

“We are confident Wisconsin’s freedom-to-work law is constitutional and will ultimately be upheld,”Walker wrote on Twitter.

Three unions filed the lawsuit last year shortly after Walker signed the bill into law. Right-to-work laws prohibit businesses and unions from reaching agreements that require all workers, not just union members, to pay union dues. Twenty-four other states have such laws.

The unions argued that Wisconsin’s law was an unconstitutional seizure of union property since unions now must extend benefits to workers who don’t pay dues. Dane County Circuit Judge William Foust agreed.

He said the law amounts to an unconstitutional governmental taking of union funds without compensation since under the law unions must represent people who don’t pay dues. That presents an existential threat to unions, Foust wrote.

“While (union) losses today could be characterized by some as minor, they are not isolated and the impact of (the law) over time is threatening to the unions’ very economic viability,” he wrote.

Foust noted that no other state court had struck struck down a right-to-work law on those grounds, but said he wasn’t obligated to follow other states.

Republicans who backed the law dismissed the ruling, saying it will be reversed.

“Once again, a liberal Dane County judge is trying to legislate from the bench,” Assembly Speaker Robin Vos, R-Rochester, said in a statement. “No one should be forced to join a union or pay union dues as a condition of employment.”

The law’s Democratic opponents of the law hailed the decision as a victory for the middle class and working families.

“The extreme right-wing Republican agenda has been incredibly harmful to working people and businesses in Wisconsin,” said Democratic Assembly Minority Leader Peter Barca.

Three unions — Machinists Local Lodge 1061 in Milwaukee, the Wisconsin AFL-CIO chapter and United Steelworkers District 2 in Menasha — brought the lawsuit. Erin Mediros, an attorney representing all three unions, didn’t immediately respond to a voicemail Friday. Karen Hickey, a spokeswoman for the AFL-CIO’s Wisconsin chapter, also didn’t immediately respond to email and voicemail messages.

The decision overturning the law comes after the same judge last year declined to put it on hold while the lawsuit moved forward.

Right-to-work supporters say such laws give workers the freedom to choose whether to join a union. Opponents say the laws weaken unions by depriving them of the dues from workers who choose not to pay them, resulting in lower wages and fewer employee rights. They also say the Republican-backed law is intended to undermine unions’ political power because unions tend to vote Democrat.

In 2014 the Indiana Supreme Court rejected two nearly identical challenges to that state’s right-to-work law. Those lawsuits alleged that the law unconstitutionally required unions to provide services to nonunion workers without compensation.

The Wisconsin attorney general argued the law doesn’t take anything from the unions since it technically doesn’t remove any money currently in their accounts.

Walker launched his run for president just months after signing the law, and frequently mentioned it while campaigning. Months after taking office in 2011, Walker also signed a law that effectively ended collective bargaining for public sector workers.

___

Associated Press writer Bryna Godar contributed to this report.

Copyright 2016 The Associated Press. All rights reserved. This material may not be published, broadcast, rewritten or redistributed.

