RALEIGH, N.C. — A federal appeals court ruled that a North Carolina law illegally targeted minorities with tougher ballot access rules, such as requiring photo identification to vote, adding a new partisan flashpoint in a swing state with a raft of hotly contested elections.

The ruling Friday by the 4th Circuit Court of Appeals declared that the 2013 law violated the Constitution and the federal Voting Rights Act by targeting black voters “with almost surgical precision.” It marks the third ruling in less than two weeks against voter ID laws after court decisions regarding Texas and Wisconsin.

The law, passed two years after Republicans took control of the state legislature for the first time in a century, sought to entrench GOP politicians in power, the opinion by a three-judge panel of the court stated.

“It did so by targeting voters who, based on race, were unlikely to vote for the majority party. Even if done for partisan ends, that constituted racial discrimination,” said the judges. The decision overturned a federal district judge’s April ruling that didn’t find proof the law made it harder for minority voters to cast ballots.

In reversing earlier election-law changes by Democrats to make voting easier, the GOP-led legislature crossed a constitutional line by restricting minority voting, the court said.

“The record thus makes obvious that the ‘problem’ the majority in the General Assembly sought to remedy was emerging support for the minority party. Identifying and restricting the ways African Americans vote was an easy and effective way to do so,” the court stated. “Winning an election does not empower anyone in any party to engage in purposeful racial discrimination.”

The decision was lauded by Democrats, including presidential nominee Hillary Clinton, as a victory for democracy and decried by Republicans as an effort to tilt the balance in elections this fall that could be won by either party.

North Carolina’s presidential race could be competitive, as Barack Obama narrowly carried the state in 2008 but lost to Mitt Romney four years later. The state that also has closely contested races for U.S. Senate and governor.

GOP legislative leaders said they would appeal the case to the U.S. Supreme Court. They blasted the ruling as a partisan and emphasized the law was intended to make voter fraud more difficult.

“Photo IDs are required to purchase Sudafed, cash a check, board an airplane or enter a federal court room. Yet, three Democratic judges are undermining the integrity of our elections while also maligning our state,” said Gov. Pat McCrory, a Republican seeking re-election.

However, it’s unlikely that the evenly divided and short-handed Supreme Court would take the case or block Friday’s ruling from governing elections this November, said election-law experts Ned Foley of Ohio State University and Richard Hasen of the University of California at Irvine. The ruling also could boost the votes at play this fall, Hasen said.

“Anytime you take away restrictions, you make it possible for more people to vote. I think we will see more people voting than if these restrictions were still in place,” he said. “I think this is a hugely important decision.”

The law’s opponents say the ruling should increase participation by black and Hispanic voters.

The photo ID requirement, which took effect with this year’s primary elections in March, required people casting ballots in person to show one of six qualifying IDs. Voters facing “reasonable impediments” could fill out a form and cast a provisional ballot.

North Carolina legislators imposed the photo ID requirement, curtailed early voting and eliminated same-day registration and voters’ ability to cast out-of-precinct provisional ballots in their home counties.

Dale Hicks said he couldn’t vote in 2014 after the new law eliminated same-day registration. The newly discharged Marine learned he couldn’t cast a ballot after moving to the Raleigh area a few months earlier.

“I felt disenfranchised, like I was being taken advantage of,” said Hicks, a 40-year-old black man. “I heard some things going on, but I didn’t think I’d be affected. I’ve been an American citizen all my life.”