MADISON, Wis.—After three years of legal battles, the war for Gov. Scott Walker’s cornerstone public-sector collective bargaining reforms ended Thursday with the state Supreme Court upholding Act 10 in its entirety.

The Supreme Court, in a 5-2 decision, with even liberal Judge Patrick Crooks agreeing Act 10 is constitutional, gave its approval to the public employee labor law that sent thousands of protesters to the state capitol and 14 Democratic senators fleeing across the state line in a bid to stop it.

All but one liberal Dane County judge had concluded Act 10 meets constitutional muster. The law holds wage negotiations to the rate of inflation, ends automatic union dues deductions and requires annual union recertification votes.

>>> Scott Walker Defends Reforms; ‘Our Most Powerful Tool Is the Truth’

The lawsuit was originally brought by Madison Teachers Inc. and Public Employees Local 61, AFL-CIO.

The labor unions argued Act 10 limited their ability to organize and right to speak under the First Amendment of the Constitution.

That position was upheld in 2012 by Dane County Circuit Judge Juan Colas, who argued that portions of Act 10 violated the constitution. But the Supreme Court disagreed.

Justice Michael Gableman, who wrote the majority opinion, asserted the unions’ “associational rights are in no way implicated by Act 10’s modifications to Wisconsin’s collective bargaining framework.” The labor unions, Gableman said, “remain free to advance any position, on any topic, either individually or in concert, through any channels that are open to the public.”