The U.S. Justice Department on Monday sued North Carolina to get it to abandon a law that restricts use of public restrooms, further escalating a fight over the rights oftransgender Americans.

Hours earlier, North Carolina Governor Pat McCrory and the state's secretary of public safety had sued the agency for declaring the law a civil rights violation, accusing it of "baseless and blatant overreach."

In March, North Carolina became the first state in the country to ban people from using multiple occupancy restrooms or changing rooms in public buildings and schools that do not match the sex on their birth certificate.

U.S. Attorney General Loretta Lynch said the department also "retains the option" of curtailing federal funding to North Carolina over the issue.

RELATED: North Carolina officials sue Justice Dept over bathroom law

"None of us can stand by when a state enters the business of legislating identity and insists that a person pretend to be something or someone that they are not," said Lynch, comparing the measure to Jim Crow-era racial discrimination laws and bans on same-sex marriage.

The Justice Department's complaint, which was filed in federal district court in North Carolina, named the state of North Carolina, McCrory, the state's Department of Public Safety and the University of North Carolina system as defendants.

The department's top civil rights lawyer, Vanita Gupta, sent letters to the same group last week, saying the ban was a civil rights violation and the state could face a federal lawsuit if it did not stop enforcing it by Monday.

The North Carolina officials sued Gupta as well as U.S. Attorney General Loretta Lynch for their "radical reinterpretation" of federal civil rights law in federal district court in North Carolina.

"We’re taking the Obama admin to court. They're bypassing Congress, attempting to rewrite law & policies for the whole country, not just NC," McCrory, a Republican, wrote on Twitter.

McCrory told reporters that North Carolina leaders had been forced to pass the law, known as HB 2, after the Charlotte city council passed an ordinance requiring access to bathrooms based on gender identity in public as well as private buildings.

The Republican leaders of North Carolina's state legislature also sued the U.S. government over the law on Monday, hours after McCrory's lawsuit.