The Justice Department on Wednesday warned North Carolina's governor that a recent anti-LGBT state law violates federal civil rights laws.

"The state is engaging in a pattern or practice of discrimination against transgender state employees," U.S. Principal Deputy Assistant Attorney General Vanita Gupta wrote in a letter to Gov. Pat McCrory.

Known as HB2, the law bans transgender people access to restrooms that match their gender identity in government buildings and schools, and in doing so, violates Title VII of the Civil Rights Act of 1964, she added.

Gupta gave McCrory until May 9 to bring North Carolina back into compliance.

The governor responded in a statement Wednesday night, saying that the Obama administration "has not only staked out its position for North Carolina, but for all states, universities and most employers in the U.S. The right and expectation of privacy in one of the most private areas of our personal lives is now in jeopardy."

McCrory, who has repeatedly claimed that transgender people pose a threat in women's restrooms, added, "We will be reviewing to determine the next steps.”

The law passed in March has faced widespread backlash from businesses and entertainers, and has triggered demonstrations from critics who say it protects those who engage in discrimination.

Jason E. Miczek / AP

Federal law prohibits workplace discrimination on the basis of sex. And both courts and the federal agency that enforces civil rights laws in the workplace have held Title VII also bans transgender discrimination, Gupta noted.

With HB2, she said, McCrory and North Carolina are engaging in a "pattern or practice of resistance" to transgender employees of public agencies fully enjoy their Title VII rights.

“Access to sex-segregated restrooms and other workplace facilities consistent with gender identity is a term, condition, or privilege of employment," Gupta wrote. "Denying such access to transgender individuals, whose gender identity is different from the gender assigned at birth, while affording it to similarly situated non-transgender employees, violates Title VII."

Further, the Education Department has interpreted Title IX of the Education Act of 1972 — which bans sex discrimination — to protect transgender students' restroom access rights. And Gupta noted that a federal appeals court recently recognized the department's authority to make that interpretation.

Gupta is asking for confirmation that North Carolina state agencies will not comply with or implement HB2.

An official with the Department of Justice, who asked not to be named because they were not authorized to speak publicly on the matter, told BuzzFeed News the agency hopes North Carolina complies voluntarily.

The DOJ prefers that states receiving federal funding will comply with U.S. law on their own so they can continue to receive the money.

However, if the state does not comply, Attorney General Loretta Lynch could seek a court order to force compliance, Gupta noted.