Gov. Pat McCrory makes remarks during a news conference in Raleigh, N.C., Monday, May 9, 2016. Gov. McCrory's administration sued the federal government Monday in a fight for a state law that requires transgender people to use the public restroom matching the sex on their birth certificate. (AP Photo/Gerry Broome)
Gov. Pat McCrory makes remarks during a news conference in Raleigh, N.C., Monday, May 9, 2016. Gov. McCrory's administration sued the federal government Monday in a fight for a state law that requires transgender people to use the public restroom matching the sex on their birth certificate. (AP Photo/Gerry Broome) Credit: Gerry Broome

Washington — The Obama administration sued North Carolina on Monday, asking a federal judge to toss out its controversial “bathroom law,” raising the political stakes in a cultural and legal battle over gender identity that has ramifications for other states and the 2016 election.

U.S. Attorney General Loretta E. Lynch personally announced the federal lawsuit, which argues that part of the state law violates the Civil Rights Act of 1964 and that the state is engaging in a “pattern or practice of sex discrimination.”

Lynch stepped in hours after North Carolina’s Republican Gov. Pat McCrory sued the Justice Department, which last week warned that a state law banning transgender people from using public bathrooms that correspond with their gender identity violates federal law.

Since the Supreme Court last year upheld the right of same-sex couples to marry, state legislatures have taken up various bills to address the extent of rights enjoyed by gays, lesbians and transgender people.

North Carolina was the first state to pass a law limiting transgender individuals’ use of public restrooms, although more than half a dozen others are weighing similar legislation.

The state lawsuit, filed earlier Monday in federal court in Raleigh, accuses the federal government of “baseless and blatant overreach” by arguing that the state law violates federal civil rights laws by blocking transgender individuals from using public restrooms corresponding to their sexual identity.

“This is an attempt to unilaterally rewrite long-established federal civil rights laws in a manner that is wholly inconsistent with the intent of Congress and disregards decades of statutory interpretation by the courts,” the state suit claims.

The Justice Department had set a Monday deadline for the state to explain how it would amend the law to meet federal standards, or face a lawsuit and the potential loss of billions of dollars in federal funding for state agencies and universities.

“Denying such access to transgender individuals, whose gender identity is different from their gender assignment at birth, while affording it to similarly situated non-transgender employees violates” federal law, wrote Vanita Gupta, who heads the department’s civil rights division.

The state law is strongly supported by social conservatives, and the battle may affect down-ballot races in the 2016 election cycle.

Although Sen. Ted Cruz, of Texas, strongly supported the North Carolina law, he dropped out of the Republican presidential race last week. Donald Trump, the presumptive GOP nominee, has suggested the new law is unnecessary.

“Leave it the way it is,” Trump said during a recent town hall. “There have been very few complaints the way it is.”

Legal experts say the Justice Department is likely to prevail in court.

They cited a recent decision by the 4th Circuit Court of Appeals, which governs federal law in North Carolina, that found a transgender high school student who was born as a female could sue his school board in Virginia for discrimination because it banned his use of the boys restroom.

The appeals court ruled 2-1 that courts should defer to an earlier U.S. Department of Education decision that transgender students can chose a restroom that corresponds to their gender identity.

“This is a contentious legal issue,” said William Yeomans, a law professor at American University and former federal civil rights lawyer. “I think the federal government’s call is the right one. The fact that a panel on the 4th Circuit upheld this view suggests the direction this is headed.”

Carl Tobias, a University of Richmond law professor, said the dispute could take more than a year to resolve and may reach the Supreme Court.

“North Carolina is on the cutting edge of this,” Tobias said, referring to the wave of pending legislation. “And on the merits, it seems to be in violation of federal law. The Justice Department has a duty to stop discrimination in the workplace and educational institutions.”

The North Carolina law, which was enacted March 23, requires transgender individuals to use public bathrooms that correspond to their biological sex or the gender listed on their birth certificates.

It also blocks local governments from allowing transgender individuals to use bathrooms that correspond to their sexual identity.

The law applies to bathrooms in government offices and facilities, including libraries and airports, universities and schools, highway rest stops and other places. It does not apply to bathrooms in private businesses.

McCrory and other state Republican leaders have defended the law as necessary to protect women against sexual assault in public bathrooms.

The state legislature passed it after the Charlotte City Council passed an ordinance in February that permitted transgender individuals to use a public restroom corresponding to their sexual identity.

The law has sparked protests from business groups, entertainers and sports teams.

PayPal last month canceled plans to open an operations center in the state, Bruce Springsteen nixed a planned concert and the NBA said it would move the All-Star game next year from Charlotte to another state if the law is not changed.

Gay rights groups have been highly critical of North Carolina’s laws and sharply criticized the governor’s decision to defend it in court.

Chad Griffin, president of the Human Rights campaign, called the law “blatantly unconstitutional.”

“The Department of Justice has already been clear that it violates the civil rights of North Carolinians,” he said in a statement. “The idea Gov. McCrory is going to waste even more time and millions more taxpayer dollars defending it is reckless and wrong.”