Democratic presidential candidates Hillary Clinton and Bernie Sanders have condemned passage of an anti-gay law in North Carolina.

Last week, North Carolina lawmakers approved and Republican Governor Pat McCrory signed into law House Bill 2, which bars any city, town or municipality from enacting measures that prohibit discrimination based on sexual orientation or gender identity. The law also makes North Carolina the first state in the nation to prohibit students in public schools from using the bathroom that does not conform to their gender at birth. Similar attempts in South Dakota and Tennessee failed this legislative session.

“It's time to end discrimination based on sexual orientation and gender identity,” Sanders tweeted on Thursday. “This law has no place in America.”

“LGBT people should be protected from discrimination under the law – period,” Clinton said in a tweet linked to a story on the law's passage.

The legislation was a response to passage of an LGBT protections ordinance in Charlotte set to take effect on April 1. State lawmakers held a one-day special session at a cost of $42,000 to pass House Bill 2.