Protesters march to show their opposition to what they called “Hate Bill 2,” a measure actually titled House Bill 2, which they urged lawmakers to repeal as legislators convened for a short session in Raleigh, N.C., on April 25, 2016. (Reuters)

The federal government took on North Carolina’s controversial “bathroom bill” Wednesday, giving the governor until Monday to pledge that he will walk away from the law, which Justice Department officials said violates civil rights.

The state risks losing hundreds of millions of dollars in federal funding if Gov. Pat McCrory (R) defies the warning and maintains his support for the measure, which requires transgender people to use bathrooms that correspond to the gender on their birth certificates.

The move sets up a confrontation between the Democratic administration and the Republican state leadership, whose swift passage of the law in an unusual March special session led to widespread public outcry, boycotts and calls for its repeal from corporate leaders. At least five federal agencies are weighing whether to withhold funds from the state. Among them is the Education Department, which, according to budget documents, provides more than $4 billion in assistance to North Carolina, much of it in the form of student loans.

A spokeswoman at the Education Department said its review was ongoing.

The Justice Department’s evaluation that it considers the law a violation of the 1964 federal Civil Rights Act and its ban on discrimination based on sex came in a letter from Vanita Gupta, the head of the Civil Rights Division. The letter was previously reported by the Charlotte Observer but confirmed to The Washington Post.

McCrory, who has defended the law as a preservation of privacy, did not respond to requests for comment. But he said in an appearance on local television Wednesday that he thought the Justice Department letter was a “pretty sweeping conclusion” from one federal agency about a law he described as a “very common-sense rule.”

North Carolina Gov. Pat McCrory accused the Department of Justice of "Washington overreach” May 4, after the federal department said that North Carolina’s bathroom law violates federal civil rights. ( / AP)

“This is no longer just a North Carolina issue, because this conclusion by the Department of Justice impacts every state, every university and almost every employer in the United States of America,” he said.

James D. Esseks, who directs the Lesbian Gay Bisexual Transgender and HIV Project at the American Civil Liberties Union, hailed the move for that very reason.

“It’s important that North Carolina understand it can’t pass a discriminatory law,” he said in an interview. “Also, it’s important that every other state understand that if it passes a similarly discriminatory law, it will pay a similar price.”

The law, enacted to prevent local governments from extending civil rights protections to gay and transgender people, has sparked controversy across the country, including heated opposition from business groups and a host of major companies. At least two companies — PayPal and Deutsche Bank — said they were scrapping planned expansions in North Carolina because of the law, moves that would cost the state hundreds of jobs as well as millions of dollars that state officials had said the companies would bring to the local economies.

Several states have introduced and passed “religious freedom” bills in the aftermath of last year’s Supreme Court decision legalizing gay marriage across the country.

On Wednesday, a group of Illinois students and parents sued the Obama administration, arguing that the Education Department is illegally forcing local authorities to let children use facilities that correspond to their gender identity. The same day, a small city in Alabama recalled its own bathroom ordinance, one that punished violators with up to six months in jail and had been passed a week earlier.

A Justice Department official said the decision to send the letter was not especially controversial, although it was reviewed by high-level officials. Administration officials debated whether the threatened loss of federal funds might be counterproductive at a time when public pressure from businesses, faith groups and other constituencies had persuaded some states to resist targeting transgender individuals.

The Obama administration has not been shy, however, in staking out its position on the issue.

Then-Attorney General Eric H. Holder Jr. said in a memo in 2014 that workplace discrimination on the basis of gender identity is prohibited under Title VII of the Civil Rights Act of 1964.

A federal appeals court in Richmond recently ruled that a transgender teen’s discrimination lawsuit against a Virginia school board could move forward. The teen, who was born female but now identifies as a boy, alleged that the school board his civil rights when it passed a policy banning him from the boys’ bathroom. The Obama administration filed a statement of interest backing the student in that case and another statement of interest supporting a transgender teen in Michigan who sued school officials for not accommodating him and for allegedly failing to address bullying.

Religious freedom proposals are being weighed in nearly a dozen states after the Supreme Court legalized gay marriage. (Claritza Jimenez/The Washington Post)

The U.S. Education Department’s Office of Civil Rights previously found that an Illinois school district violated the law when it banned a transgender girl from the girls’ locker room. Department officials told the district that it risked losing federal funding if it did not accommodate the student.

And President Obama, in a youth town hall in London, said the law in North Carolina and a similar one in Mississippi “are wrong and should be overturned.”

“I think it’s very important for us not to send signals that anybody is treated differently,” he said.

North Carolina Attorney General Roy Cooper (D) has already said he would not defend his state’s law, and in a statement Wednesday, he called on the governor to advocate for its repeal.

“Enough is enough,” said Cooper, who will face McCrory in a competitive gubernatorial election in November. “It’s time for the governor to put our schools and economy first and work to repeal this devastating law.”

McCrory, who signed the law in March, has repeatedly defended the measure since then, arguing that it is needed to protect people’s privacy.

He has criticized what he described as “a vicious nationwide smear campaign” against the measure and claimed that Obama’s goal is “to force our high schools to allow boys in girls’ restrooms.”

Transgender advocate Candis Cox, 35, of Raleigh called the federal intervention “a true triumph.”

“Having the Justice Department on our side says that this is not just a matter of social discretion or saying there’s something morally wrong here,” she said, “but this is something that goes against our country and the laws that we as a nation put into place.”

Moriah Balingit, Emma Brown, Juliet Eilperin and Sandhya Somashekhar contributed to this report.