LANSING, Michigan — Michigan’s Republican-controlled Legislature passed separate bills on Thursday aimed at making the home of the U.S. auto industry the 24th “right-to-work” state banning mandatory union dues, setting off raucous demonstrations and the arrests of some protesters.

The Michigan House of Representatives voted 58-52 to approve a measure that would make payment of union dues voluntary in the private sector, after Democrats walked out in protest at the public being kept out of the Capitol.

A few hours later, the state Senate passed a different “right-to-work” bill in a 22-16 vote. Each measure must be sent for consideration to the other chamber before receiving final legislative approval.

Republican Governor Rick Snyder has pledged to sign the bills once they are passed. Snyder, who said last year that “right-to-work” legislation would be divisive for the state, said this week he now supported it.

Thousands of union workers converged on the state capital, Lansing, to protest the sudden drive for the law, and officials closed the Capitol building’s doors for hours, citing safety concerns.

Several people were arrested while demonstrating inside the Capitol building when they tried to rush past troopers outside the Senate chambers, State Police spokesman Gene Adamczyk said. The protests recalled the bitter two-year fight in Wisconsin, where Republicans voted to curb the powers of public-sector unions.

The 2011 Wisconsin law sparked massive protests and an unsuccessful effort to recall Republican Governor Scott Walker. Approval of such legislation in the union stronghold of Michigan would be a major blow to organized labor. Michigan is where the headquarters of General Motors, Ford Motor Co and Chrysler are located, and is the home of the United Auto Workers union.

“It’s another attack on the middle class,” UAW President Bob King said in an interview. “The wealthy are never satisfied.”

King said that if the law were passed, the union would try to overturn it at the ballot box through a referendum.

Republicans intend to pass separate measures applying to public-and private-sector unions. They are rushing to finish by the end of the year because Democrats gained five seats in the state House in the November election, narrowing the Republican majority in the new Legislature convening in January.

Michigan would be the second state in the industrial U.S. heartland to adopt such a law after Indiana earlier in 2012, and the 24th in the nation, although most are in the South.