CHARLESTON, W.Va. — West Virginia’s highest court ruled Friday that a judge made a mistake blocking the state’s “right-to-work” law from taking effect after it was passed last year while the court challenge against it continued.

The Supreme Court, divided 3-2, concluded the unions opposing the law “failed to show a likelihood of success” in challenging its constitutionality.

They didn’t identify any federal or state appellate court that struck down such a law based on similar challenges in more than 70 years, Justice Menis Ketchum wrote. He noted that similar laws have been enacted in 27 other states.

The state AFL-CIO and other unions argued the law constitutes illegally taking union assets since they still have to represent all employees in a union shop, including those that the law would allow to stop paying union dues. They also asserted that it violated their rights to freedom of association and their liberty interests.

Kanawha County Circuit Judge Jennifer Bailey granted the preliminary injunction, saying enforcement could cause irreparable harm to unions and workers until the legal questions are resolved.

The law doesn’t affect existing contracts, only future agreements the union and employers have not yet negotiated or accepted, Ketchum wrote. “The unions therefore have no protected property right that the Legislature has taken,” he wrote.

In a concurring opinion, Justice Allen Loughry wrote that issuing the injunction “was not merely imprudent, but profoundly legally incorrect.” The Taft-Hartley Act expressly allows states to prohibit compulsory union membership or dues remittance, and the U.S. Supreme Court “has essentially spoken on all critical aspects of this issue,” he wrote.

The law was passed in early 2016 by the Legislature’s majority Republicans. They contended it would attract businesses and give workers freedom by prohibiting companies from requiring employees to pay union dues as a condition of employment.

Democrats argued the measure solely aimed to undermine unions for political reasons, allowing workers to benefit from union representation without paying dues. Democrats also argued the economic benefits were unproven and wages would drop.

Justice Robin Jean Davis dissented in an opinion that wasn’t available from the court Friday. Justice Margaret Workman agreed in part and dissented in part in an opinion that also was not immediately available.