The Department of Justice has given Gov. Pat McCrory of North Carolina until Monday to abandon the state’s discriminatory law barring transgender people from using public restrooms based on their gender identity. The law also blocked Charlotte’s antidiscrimination ordinance, and prohibited cities and counties from enacting similar laws.

In a letter issued Thursday, the Justice Department’s top civil rights prosecutor, Vanita Gupta, warned the governor that the statute, which was passed in March, violates federal civil rights law. She said that the Department of Justice may sue North Carolina and that the Department of Education may withhold federal funding for its schools.

The state law peddles the malicious idea that transgender people are sexual predators and that allowing people to use a bathroom that reflects their gender identity violates the rights of others. It immediately drew a strong backlash from civil rights groups, religious leaders and businesses. Major corporations have decried the law, calling it an impediment to recruiting and retaining top talent. Employers have already suspended plans to expand operations in North Carolina, costing the state hundreds of jobs.

Mr. McCrory, a Republican, and his allies in the state’s legislature, the General Assembly, have tried to cast themselves as the victims of a radical progressive agenda. Yet the governor may be belatedly recognizing that he is the one pursuing radical ends in a society that has come to more deeply understand and accept variations of gender identity.