Carlos Osorio / AP
Union workers fill the entire of the Michigan's Capitol rotunda in Lansing, Mich., on Thursday.
By Vignesh Ramachandran
Updated at 7:55 p.m. ET: Police doused demonstrators with pepper spray in Michigan?s state Capitol building Thursday, but the protests didn't stop right-to-work legislation from passing the state legislature.
To the dismay of labor unions, Michigan?s House passed a bill 58-52, with all Democrats and some Republicans voting against it, the Lansing State Journal reported. Michigan's Senate later followed, passing its own version of the bill with a 22-16 vote, according to the newspaper.
Gov. Rick Snyder has pledged to sign a right-to-work bill if the House and Senate can agree on a version.
Armed with a court order,?protesters?re-entered the state Capitol in Lansing on?Thursday afternoon, The Associated Press reported. Earlier in the day, the building was under lockdown after demonstrators flooded the Capitol. In protest of the lockdown, the Democratic caucus had walked out of the chamber before the vote on the bill, the State Journal reported.
"Right-to-work" measures can prohibit unions from collecting fees from nonunion employees, potentially draining unions of money and their ability to bargain, according to the AP. However, supporters claim these sort of measures would help job creation and the economy, the AP reported.
Carlos Osorio / AP
David Dudenhoefer, left, a right-to-work supporter, receives a thumbs down sign from a union worker during a rally in Lansing, Mich., on Thursday.
Police arrested eight protesters among the mass of hundreds inside the Capitol earlier in the day, the AP reported. The unrest was sparked by Gov. Rick Snyder and the Republican-controlled state legislature's moves to introduce the legislation, according to the AP.
Authorities said crowds tried to rush the Senate floor, the State Journal also reported. The?building's?entrance?was reportedly blocked by police for safety, though hundreds waited to get inside, according to the newspaper.
Stay informed with the latest headlines; sign up for our newsletter?
"When several of the individuals rushed the troopers, they used chemical munitions to disperse the crowd,"?Michigan State Police Inspector Gene Adamczyk told the State Journal. "It would be a lot worse if someone gets hurt and I failed to act."
Protesters also marched to the nearby Michigan Chamber of Commerce headquarters, which supports right-to-work legislation,?the capital city's NBC affiliate WILX reported.
Some of the anger could stem from what appears to be the Republican governor's flip-flop. In his first two years in office, Snyder claimed right-to-work legislation was off his agenda, according to the AP.
But during a news conference, Snyder said, "This is all about taking care of the hard-working workers in Michigan, being pro-worker and giving them freedom to make choices."?
"These guys have lied to us all along the way," Michigan?Senate Democratic leader Gretchen Whitmer told the AP. "They are pushing through the most divisive legislation they could come up with in the dark of night, at the end of a lame-duck session and then they're going to hightail it out of town. It's cowardly."
Carlos Osorio / AP
Union workers rally outside the Michigan Capitol in Lansing, Mich., on Thursday.
The issue hits close to the heart of organized labor in the "Rust Belt" region.?
Michigan, home to the United Auto Workers, has the fifth highest percentage of unionized workers among states, according to government figures cited by Reuters. In November, state voters rejected a ballot?initiative?that would have barred right-to-work measures under the state constitution, the AP reported.
A right to work law was passed in Indiana earlier this year.
In Wisconsin, huge protests occurred in 2011 after Republicans pushed through legislation restricting public-sector unions. Opponents of the legislation unsuccessfully attempted to recall Gov. Scott Walker.
The Associated Press contributed to this report.
More content from NBCNews.com:
Follow US news from NBCNews.com on Twitter and Facebook