WINSTON-SALEM, N.C. (Reuters) - North Carolina’s governor on Wednesday signed into law a measure that blocks local governments in the state from enacting ordinances to allow transgender people to use public bathrooms that match their gender identities.

The legislation came in response to such a provision approved last month in Charlotte, the state’s largest city, as part of an expanded nondiscrimination ordinance that also added protections for marital and familial status, sexual orientation, gender expression and gender identity.

The bill passed both chambers of the legislature during a one-day special session convened in Raleigh to address the Charlotte law. Republican Governor Pat McCrory, who signed the bill late on Wednesday, said the Charlotte measure “defies common sense.”

“The basic expectation of privacy in the most personal of settings, a restroom or locker room, for each gender was violated by government overreach and intrusion by the mayor and city council of Charlotte,” McCrory said in a statement.

Controversy over the bathroom component echoed similar fights across the country as transgender advocates push for the right to choose restrooms and locker rooms, including in schools, based on gender identity rather than birth gender.

Republican lawmakers in North Carolina warned that the “radical” Charlotte measure would create a public safety issue by giving men, including sex offenders, access to women’s bathrooms if allowed to take effect on April 1.

“This is a common sense bill that protects the privacy expectations of our citizens while clarifying local authority,” said Republican Representative Paul Stam.

Lesbian, gay, bisexual and transgender advocacy groups condemned the law’s passage and said they were exploring legal challenges.

They say no public safety risks had resulted in the more than 200 U.S. cities that have enacted protections similar to those passed in Charlotte.

“We are disappointed that Governor McCrory did not do right by North Carolina’s families, communities, and businesses by vetoing this horribly discriminatory bill,” said Chris Brook, legal director of the state’s American Civil Liberties Union.

The bill requires multiple-occupancy bathrooms and locker rooms in public schools and government buildings to be used by people only according to their biological sex.

The measure also creates North Carolina’s first statewide nondiscrimination policy for public places, including restaurants, hotels and taxis. But it limits the protections against discrimination to race, religion, color, national origin and biological sex.

Local governments would be prohibited from passing anti-discrimination ordinances that extended the protections to include gender identity and sexual orientation.