By Julia Harte and Andy Sullivan

WASHINGTON (Reuters) - A U.S. appeals court on Friday struck down a North Carolina law that required voters to show photo identification when casting ballots, ruling that it intentionally discriminated against African-American residents.

The ruling, a victory for rights advocates that will enable thousands of people to vote more easily, is also likely to be seen as a boost for Democratic presidential nominee Hillary Clinton going into the election on Nov. 8.

The state is politically important as it does not lean heavily toward either Democrats or Republicans, and Clinton is heavily favored among black Americans over Republican nominee Donald Trump.

The court's decision also canceled provisions of the law that scaled back early voting, prevented residents from registering and voting on the same day, and eliminated the ability of voters to vote outside their assigned precinct.

Critics argue that such provisions are designed to drive down turnout by minorities and poor people who rely more on flexible voting methods and are less likely to possess state-issued photo IDs. Proponents of such laws say they aim to eliminate voter fraud.

In its ruling, a three-judge panel at the U.S. Appeals Court for the Fourth Circuit said the state legislature targeted African-Americans "with almost surgical precision."

"We cannot ignore the recent evidence that, because of race, the legislature enacted one of the largest restrictions of the franchise in modern North Carolina history," Judge Diana Motz wrote.

U.S. Attorney General Loretta Lynch said the court's ruling upheld Americans' ability "to have a fair and free opportunity to help write the story of this nation," in remarks she delivered on Friday in Baton Rouge, Louisiana.

The Republican leaders of North Carolina's state legislature vowed to appeal the ruling to the U.S. Supreme Court. In a joint statement they argued the decision ignored legal precedent.

"We can only wonder if the intent is to reopen the door for voter fraud, potentially allowing fellow Democrat politicians like Hillary Clinton and (state Attorney General) Roy Cooper to steal the election," said the statement from state lawmakers Phil Berger and Tim Moore.

North Carolina Governor Pat McCrory, a Republican who is up for re-election in November, also said the state would appeal the ruling and "review other potential options."

The chances of any appeal being heard before the election appeared slim. The state's board of elections said the law's voting rules would not be in effect in November, "absent alternative guidance from the courts."

Voting rights advocates heralded the court's decision as a major victory.

"This ruling is a stinging rebuke of the state's attempt to undermine African-American voter participation, which had surged over the last decade," Dale Ho, director of the Voting Rights Project at the American Civil Liberties Union, said in a statement.

North Carolina’s legislature passed the voting law weeks after the U.S. Supreme Court voted 5 to 4 in June 2013 to eliminate a requirement that states with a history of discrimination, including North Carolina, receive federal approval before changing election laws.

A campaign spokesman for Cooper said on Friday that the attorney general had "urged the Governor to veto this legislation before he signed it because he knew it would be bad for North Carolina."

A Reuters review of the law indicated that as many as 29,000 voters might not have been counted in this November's election if the bans on same-day registration and out-of-precinct voting had remained in effect.

(Additional reporting by Colleen Jenkins in Winston-Salem, N.C.; Editing by Frances Kerry)