Get breaking news alerts and special reports. The news and stories that matter, delivered weekday mornings.

MADISON, Wis. — 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.

Attorney General Brad Schimel, also a Republican, promised to appeal the decision and said he was confident it would not stand, noting that no similar law has been struck down in any other state. Schimel has not decided 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-five 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 the government taking 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.

Let our news meet your inbox. The news and stories that matters, delivered weekday mornings. This site is protected by recaptcha

"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.

Wisconsin Gov. Scott Walker, seen here delivering his State of the State address in Madison, Wis., on Jan. 19, championed the right-to-work bill. Amber Arnold / Wisconsin State Journal via AP

Foust noted that no other state court had 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 supporters 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.

Phil Neuenfeldt, president of the Wisconsin AFL-CIO, said the ruling was a "needed check on Scott Walker's attacks on working families."

"Right to work has always been unjust, now it's proven unconstitutional," he said.

Supporters of right-to-work laws say they 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.