A Dane County judge has struck down Wisconsin’s right-to-work law.

Dane County Judge William Foust issued a ruling Friday overturning the law, which bans contract clauses that make payments to unions a condition of working at certain companies. Gov. Scott Walker signed legislation on March 9, 2015, making Wisconsin the United States’ 25th right-to-work state.

The Wisconsin State AFL-CIO, United Steelworkers District 2 of Menasha and Machinists Local Lodge 1061 of Milwaukee responded the following day with a lawsuit against Walker and several other defendants.

The unions’ civil complaint contends Wisconsin’s right-to-work law violates the state constitution’s prohibition against the taking of property without providing just compensation. The plaintiffs argue that they have a property interest in contractual language that, before the adoption of right-to-work, allowed them to collect dues from even nonunion members at certain companies.

Critics of right-to-work laws contend that unions are legally required to represent all employees at so-called union-shop companies, regardless of whether those workers formally belong to the union. The groups suing Walker say they count on the income they receive from mandatory dues to pay for that required representation.

Defenders of Wisconsin’s right-to-work law countered by saying that labor organizations actually have a choice over whether they will represent all employees at a company, rather than just those who have chosen to join the union. For that reason, the defenders argued, unions could avoid any harm arising from right to work simply by limiting their representation to employees who pay dues.

Judge Foust rejected that argument on Friday. He wrote that federal labor-case law has made it clear that unions cannot pick and choose which employees they will represent.

Calling right-to-work defenders’ arguments disingenuous, Foust wrote, “if the union exists at all … and is chosen by a majority of the employees voting in a collective bargaining unit, then it must be the employees’ exclusive representative. It cannot decline exclusive representative status unless it declines to be voted in at a workplace to begin with.”

Foust found that Wisconsin’s right-to-work law in essence constituted a “taking” of unions’ property and, for that reason, was unconstitutional.

Besides Walker, the groups filed suit against Attorney General Brad Schimel, and two commissioners at the Wisconsin Employment Relations Commission: James Scott and Rodney Pasch.

Wisconsin’s right-to-work law has been cited by top Republican lawmakers as among their main accomplishments from the just-ended legislative session. Assembly Speaker Robin Vos, R-Rochester, responded to the news Friday by saying that “once again a liberal Dane County judge is trying to legislate from the bench.”

Right to work aside, Dane County judges had also handed down rulings overturning parts of Wisconsin’s Act 10 legislation, the 2011 law that all but eliminated most public employees’ collective-bargaining rights. Vos and others said Friday that they believe that Wisconsin’s right-to-work law will be similarly upheld on appeal.

“No one should be forced to join a union or pay union dues as a condition of employment,” Vos said in a statement. “I’m confident that this decision will be reversed in a higher court and worker freedom will prevail.”

Schimel, a Republican, responded by saying: “We are extremely disappointed that the Dane County Circuit Court struck down Wisconsin’s right-to-work law, but we are confident the law will be upheld on appeal.”

Democrats, meanwhile, hailed Foust’s ruling.

“It is especially disturbing to me that the ‘Right to Work’ bill was rammed through the legislature in a matter of weeks, yet Republicans took no meaningful action this session to grow Wisconsin’s economy and rebuild the middle class,” Assembly Minority Leader Peter Barca, D-Kenosha, said in a statement.

Opponents of right-to-work laws face a substantial hurdle embedded in federal law. The Taft-Hartley Act of 1947 explicitly allows states to adopt right-to-work laws prohibiting labor contracts that require the payment of union dues as a condition of employment at certain companies.

Patrick Semmens, vice president for the National Right to Work Legal Defense Foundation, has said opponents are also fighting an uphill battle when they try to argue that state laws – even those contained in a state constitution – should trump a federal act.

Foust noted in Friday’s ruling no other state court had struck down a right-to-work law on the same grounds he was citing. But, he added, he is not obliged to follow other states.

The Associated Press contributed to this story.