MADISON, Wis. — A Wisconsin appeals court upheld the state’s right-to-work law on Tuesday, handing Gov. Scott Walker a victory by reversing a lower court ruling that had struck down the law as unconstitutional last year.

The 3rd District Court of Appeals rejected the challenge brought by three unions — the AFL-CIO’s Wisconsin chapter, Machinists Local Lodge 1061 and United Steelworkers District 2. The law has been in effect while the court challenge was pending.

“I applaud the court in affirming the constitutional right of all Wisconsin workers to be free to choose whether they want to join a union or financially support a union,” Walker said in a statement.

Right-to-work laws prohibit businesses and unions from reaching agreements that require all workers, not just union members, to pay union dues.

Since unions must represent all employees in a workplace, the laws essentially allow nonunion workers to benefit from union representation for free.

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 for Democrats.

Walker, a Republican, signed the right-to-work bill into law in March 2015, one of several measures he has enacted as governor that weaken union rights. He’s most well-known for a 2011 law that effectively ended collective bargaining for most public workers.

This year’s state budget, which Walker is expected to sign any day, ends a requirement that workers on state construction projects be paid a prevailing wage, a change fought by unions.

Last year, Dane County Circuit Judge William Foust sided with the unions and struck down the right-to-work law as unconstitutional, saying it wrongly enabled nonunion workers to receive free representation.

His ruling was put on hold by the state appeals court. On Tuesday, the court rejected the unions’ argument, saying unions are bound to represent even those who choose not to pay dues.

“The law merely prohibits anyone from conditioning a person’s employment on the payment of monies designed to cover the costs of performing that duty of fair representation,” the three-judge appeals court said.

Republican Attorney General Brad Schimel, who defended the law, said the ruling vindicated the state’s position. Fred Perillo, attorney for the unions, was out of the office and did not immediately return a message seeking comment.

The ruling could be appealed to the state Supreme Court, where conservatives hold a 5-2 majority.

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.

Wisconsin is one of 28 states with a right-to-work law.