A gender-neutral restroom is seen at the University of California, Irvine, Sept. 30, 2014. Reuters

North Carolina lawmakers passed a bill Wednesday to prevent cities and counties from passing laws to protect the LGBT community against discrimination. Gov. Pat McCrory, a Republican, signed the bill into law.

The moves came after the city council in Charlotte approved an anti-discrimination law that would allow transgender people to use restrooms that reflect their gender identity.

The new law, House Bill 2, is an anti-discrimination measure that does not apply to the lesbian, gay, bisexual and transgender population. The law bans employers and businesses from discriminating against their employees or clientele based on race, country of origin, religion, age or biological sex, according to the Huffington Post. The measure also includes a provision requiring people to use public restrooms that correspond with their gender at birth. It will go into effect April 1.

McCrory released a statement Wednesday evening on why he signed House Bill 2, or the Public Facilities Privacy and Security Act. "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," he said in the statement. "This radical breach of trust and security under the false argument of equal access not only impacts the citizens of Charlotte but people who come to Charlotte to work, visit or play."

The bill passed by a wide margin in the House of Representatives with a 83-25 vote and in the Senate by 32-0, the Associated Press reported. Democrats in the Senate walked out before the vote in protest.

“This bill essentially repeals 50 years of non-discrimination efforts and gives lawmakers in Raleigh [the state capital] unprecedented control over our city and local governments,” Senate Democratic Leader Dan Blue said in a statement. “North Carolina Republicans want to pass what would potentially be the single most discriminatory act in the country. This is a direct affront to equality, civil rights, and local autonomy.”

Advocates of the bill said that they voted to prevent laws from being enacted, such as the one in Charlotte, that would allow transgender people to use the restroom of the gender they identify with. "We came here to undo what happened in one county,” said Sen. Warren Daniel, a Republican, told the Charlotte Observer.

Sarah Kate Ellis, president of GLAAD (an LGBT advocacy group) called the new law "hateful."

"North Carolina's legislature is unfairly targeting LGBT families across the state with this harmful bill," she said. "House Bill 2 is not only an attack on Charlotte's recently passed nondiscrimination ordinance, it's an attack on the safety and freedom of all LGBT North Carolinians. Legislators are wasting taxpayer dollars in this special session to write discrimination into law. Governor McCrory has an obligation to protect all North Carolinians by vetoing this hateful bill."