WASHINGTON — The Justice Department warned the State of North Carolina on Wednesday that its new law limiting bathroom access violated the civil rights of transgender people, a finding that could mean millions of dollars in lost federal funds.

In a letter to Gov. Pat McCrory, Vanita Gupta, the top civil rights lawyer for the Justice Department, said that “both you and the State of North Carolina” were in violation of civil rights law, and gave him until Monday to decide “whether you will remedy these violations.”

A Justice Department official said that federal officials hoped that the state would agree to comply voluntarily with federal civil rights law by abandoning the measure. But the department has a number of tools it can use to try to force compliance, including denying federal funds or asking a court to do so, said the official, who spoke on condition of anonymity.

The ultimatum escalated a contentious national debate over North Carolina’s new legal stance on transgender and gay people, and set up what could be a lengthy showdown between the state and the Obama administration.