A federal judge ruled Friday that two portions of a Wisconsin law that curbs collective bargaining rights of most public employees is unconstitutional, though he left most of the legislation intact.

Seven big unions had sued, seeking reversal of the law pushed last year by Republican Gov. Scott Walker. On Friday, U.S. District Judge William Conley in Madison, Wis., sided with the unions on two sections -- a ban on letting government workers have dues automatically deducted from their paychecks, and a costly requirement that unions convene once a year to recertify themselves based on votes of all members not just those in attendance.

The coalition of unions filed the lawsuit last summer shortly after the controversial law was passed by Wisconsin's Republican-controlled Legislature and signed into law by Walker. 

The unions argued that the law violated the U.S. Constitution by taking away workers' rights to bargain and organize, and discriminated against certain public-sector employees while exempting others, such as firefighters and police officers.

So long as the State of Wisconsin continues to afford ordinary certification and dues deductions to mandatory public safety unions with sweeping bargaining rights, there is no rational basis to deny those rights to voluntary general unions with severely restricted bargaining rights, Conley wrote.

The judge ordered that automatic dues deductions for public unions to be reinstated no later than May 31.

The labor law was met with massive protests in the Wisconsin's capital, Madison, in February and March 2011, including inside the state legislature's chambers. The angry backlash against Walker fueled a successful petition for the governor to face a recall election. Wisconsin voters will get the chance on June 5 to vote Walker out of office.