This story was last updated at 9:46 a.m.

By GARY D. ROBERTSON, Associated Press and EMERY P. DALESIO, Associated Press

RALEIGH, N.C. (AP) — Sparked by backlash to Charlotte's ordinance allowing transgender people to use restrooms aligned with their gender identity, the North Carolina legislature reined in local governments with a broad bill the prevents cities and counties from passing their own anti-discrimination rules. Republican Gov. Pat McCrory signed the legislation Wednesday night, dealing a blow to the LGBT movement after success with protection in cities across the country.

The Republican-controlled General Assembly took action Wednesday to invalidate Charlotte's ordinance after city leaders last month approved the broad anti-discrimination measure. Critics focused on language in the ordinance involving transgender people and restrooms.

McCrory, who was the mayor of Charlotte for 14 years and had criticized the local measure, signed the legislation that he said was "passed by a bipartisan majority to stop this breach of basic privacy and etiquette."

Although 12 House Democrats joined all Republicans present in voting for the bill in the afternoon, later all Senate Democrats in attendance walked off their chamber floor during the debate in protest. Remaining Senate Republicans gave the legislation unanimous approval.

"We choose not to participate in this farce," Senate Minority Leader Dan Blue of Raleigh said after he left the chamber.

Senate leader Phil Berger of Eden said the Democrats' decision to leave was a "serious breach of their obligation to the citizens that voted to elect them."

Republicans and their allies have said intervening is necessary to protect the safety of women and children from "radical" action by Charlotte. There have been arguments that any man — perhaps a sex offender — could enter a woman's restroom or locker room simply by calling himself transgender.

"It's common sense — biological men should not me be in women's showers, locker rooms and bathrooms," said GOP Rep. Dean Arp of Monroe before the chamber voted 82-26 for the legislation after nearly three hours of debate.

Gay rights leaders and transgender people said the legislation demonizes the community and espouses bogus claims about increasing the risk of sexual assaults. They say the law will deny lesbian, gay, bisexual and transgender people essential protections needed to ensure they can get a hotel room, hail a taxi or dine at a restaurant without fear.

"McCrory's reckless decision to sign this appalling legislation into law is a direct attack on the rights, well-being and dignity of hundreds of thousands of LGBT North Carolinians and visitors to the state," Human Rights Campaign President Chad Griffin said in a statement. Civil liberties groups pledged to push for repeal and were weighing legal options. A Thursday evening rally was planned.

GOP leaders scheduled the one-day session at the cost of $42,000 because Charlotte's ordinance was set to take effect April 1. Otherwise, the legislature wouldn't have returned until late April.

Current Charlotte Mayor Jennifer Roberts, who pressed to get the anti-discrimination ordinance approved, said she was appalled by the legislature's actions.

"The General Assembly is on the wrong side of progress. It is on the wrong side of history," Roberts said in a statement. But McCrory said in a release "the basic expectation of privacy in the most personal of settings" was violated by "government overreach and intrusion" by Roberts and the city council.

The law bars local governments statewide from prohibiting discrimination in public places based on sexual orientation and gender identity. A new statewide nondiscrimination law included doesn't contain those specific protections. It directs all public schools, government agencies and public college campuses to require bathrooms or locker rooms be designated for use only by people based on their biological sex. They can offer single-occupancy facilities.

Transgender people who have transitioned to the opposite sex wouldn't be affected if they get their birth certificate changed.

Democrats said the measure makes North Carolina less inclusive and interferes with local governments. They say the state could also risk billions in federal education dollars with the school policy.

Ordinance supporters and opponents spoke to legislators in House and Senate committees. They included Skye Thompson, 15, of Greenville, who was born female but now identifies as male. He told senators they were putting him in danger by requiring use of a women's restroom.

"I've dealt with bullying my whole life and now I worry that my own state lawmakers are bullying me as well. I feel bullied by you guys," Thompson said.

Donna Eaton of Cary said everybody deserves to be treated with dignity and respect but is worried that without Wednesday's legislation "it's going to open the door for people with malicious intent who would masquerade as transgenders to come in and actually take advantage and have access to our kids."

Legislation requiring transgender students to use bathrooms corresponding with their birth gender have failed recently. South Dakota's legislature failed to override Gov. Dennis Daugaard's veto and a similar bill in Tennessee bill died Tuesday.

The new law also would also make clear local governments can't require area businesses to pay workers above the current minimum wage, with some exceptions. McCrory said that although items beyond the bathroom-related provisions in the legislation should have waited until later this spring for debate, he signed it anyway because it doesn't change existing rights under state or federal law.