Image copyright Reuters Image caption The law required voters to show photo identification and cut short early voting hours

A US appeals court has overturned a controversial North Carolina law that requires voters to show identification before casting their ballots.

The three-judge panel ruled the Republican-backed law was intended to discriminate against black voters.

The ruling also restored same-day voter registration and out-of-precinct voting as well as extended early voting.

The unanimous decision was considered a victory for the US Justice Department and civil rights activists.

The 2013 state law made sweeping changes to election rules, including requiring voters to show an accepted form of photo identification, eliminating same-day voting, ending out-of-precinct voting and cutting short the early voting period.

"We can only conclude that the North Carolina General Assembly enacted the challenged provisions of the law with discriminatory intent," Judge Diana Gribbon Motz wrote for the Fourth US Circuit Court of Appeals in Richmond, Virginia.

The decision reversed a lower court ruling in April, which upheld the voting rules law.

The Justice Department had argued the law unfairly targeted African-American voters in the state.

North Carolina is considered a key battleground state that could determine the outcome of the presidential election in November.

Image copyright Getty Images Image caption North Carolina is one of a handful of competitive states in the US presidential election

State lawmakers defended the law as a means of preventing voter fraud.

The decision is one of three rulings this month that has invalidated restrictive state voter identification regulations.

Last week, a federal appeals court ruled against Texas' strict voter identification law, saying it discriminated against minorities and must be softened before the November elections.

A district court blocked a similar law in Wisconsin. though the decision is being appealed.