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".

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

"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 Mrs 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 lavatories based on gender identity in public as well as private buildings.

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