The Obama administration and the North Carolina government have traded accusations of civil rights violations and government overreach over access to toilets for trans people.
The US Justice Department's complaint asked a federal district court in North Carolina to declare that the state is violating the 1964 Civil Rights Act and order it to stop enforcing the ban.
Hours earlier, North Carolina's Republican governor, Pat McCrory, and the state's secretary of public safety sued the agency in a different federal court in North Carolina, accusing it of "baseless and blatant overreach."
The so-called bathroom law, passed in March and known as HB 2, prohibits people from using public restrooms not corresponding to their biological sex.
It has thrust North Carolina into the center of a national debate over equality and privacy, and has now led the state into what could be a long and costly legal battle with the US government.
Americans are divided over how public restrooms should be used by transgender people, according to a Reuters/Ipsos poll, with 44 percent saying people should use them according to their biological sex and 39 percent saying they should be used according to the gender with which they identify.
By passing the law, 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.
US Attorney General Loretta Lynch said on Monday the department "retains the option" of curtailing federal funding to North Carolina unless it backs down.
"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," Lynch said at a news conference, comparing the measure to Jim Crow-era racial discrimination laws and bans on same-sex marriage.