The North Carolina Attorney General's office said it would not defend a new state law being challenged in federal court by opponents who say it discriminates against lesbian, gay, bisexual and transgender people.

Attorney General Roy Cooper, a Democrat who is running for governor this year, on Tuesday called the measure shameful and unconstitutional. It requires transgender people to use bathrooms that match the gender on their birth certificate rather than the one with which they identify.

"Not only is this new law a national embarrassment, it will set North Carolina's economy back if we don’t repeal it," Cooper said at a news conference.

Senate Leader Phil Berger, a Republican, fired back with a statement calling for Cooper to resign from office for refusing to defend the state against the lawsuit.

"His zeal for pandering for the extreme left's money and agenda in his race for governor is making it impossible for him to fulfill his duties as attorney general," Berger said.

Advocacy groups sued North Carolina on Monday in response to state lawmakers' repeal last week of a Charlotte city ordinance that would have allowed bathroom choice based on gender identity.

The Republican-dominated legislature and Governor Pat McCrory also have come under fire from major corporations and the White House for the measure, which was introduced, passed and signed into law during a one-day special session.

The law prohibits local governments from enacting anti-discrimination protections based on sexual orientation and gender identity.

Cooper said the measure conflicted with the nondiscrimination policy adopted by his office in 2001 that extended protections based on sexual orientation and marital status.

Cooper, who was first elected attorney general in 2000 and is now running against McCrory, advised the governor and legislature to scrap the law.

"Discrimination is wrong, period," Cooper said.

(Reporting by Colleen Jenkins; Editing by Lisa Von Ahn)