Updated on July 29 at 9:30 p.m.

DURHAM, N.C.—The Fourth Circuit Court of Appeals struck down key portions of North Carolina’s strict 2013 voting law on Friday, delivering a stern rebuke to the state’s Republican General Assembly and Governor Pat McCrory. The three-judge panel in Richmond, Virginia, unanimously concluded that the law was racially discriminatory, and it blocked a requirement that voters show photo identification to vote and restored same-day voter registration, a week of early voting, pre-registration for teenagers, and out-of-precinct voting.

“In what comes as close to a smoking gun as we are likely to see in modern times, the State’s very justification for a challenged statute hinges explicitly on race—specifically its concern that African Americans, who had overwhelmingly voted for Democrats, had too much access to the franchise,” wrote Judge Diana Gribbon Motz.

North Carolina’s law, often described as the strictest in the nation, passed shortly after the Supreme Court struck down Section 5 the Voting Rights Act in Shelby County v. Holder. That section required states with a history of voter discrimination to “preclear” any changes to voting laws with the U.S. Department of Justice. Freed from that requirement, the General Assembly passed a slate of changes, including the photo-ID requirement. Both sides effectively agreed that these changes disproportionately affected poor, elderly, and African American voters, who were less likely to hold the required forms of photo ID, more likely to move frequently, and more likely to take advantage of early voting. These voters also vote overwhelmingly Democratic.

“In North Carolina, restriction of voting mechanisms and procedures that most heavily affect African Americans will predictably redound to the benefit of one political party and to the disadvantage of the other,” Motz wrote. “As the evidence in the record makes clear, that is what happened here.”

A range of plaintiffs, including the North Carolina NAACP, the Advancement Project, and the Department of Justice quickly sued the state over the law. In April, federal district-court Judge Thomas Schroeder upheld the law, finding that plaintiffs had “failed to show that such disparities will have materially adverse effects on the ability of minority voters to cast a ballot and effectively exercise the electoral franchise.”

Echoing Chief Justice John Roberts’s opinion in Shelby County, Schroeder stated that while the Old North State had a shameful history of racial discrimination, it was just that—history. “There is significant, shameful past discrimination. In North Carolina's recent history, however, certainly for the last quarter century, there is little official discrimination to consider,” he wrote.

The circuit court rebuked Schroeder, saying that the district court had “fundamentally erred” and “seems to have missed the forest in carefully surveying the many trees.” For example, Friday’s decision noted, black participation in elections had been rising steadily in the year before the law passed, periodically bolstered by federal intervention. “Not coincidentally, during this period North Carolina emerged as a swing state in national elections,” Motz drily noted. She also wrote:

The General Assembly enacted [these changes] in the immediate aftermath of unprecedented African American voter participation in a state with a troubled racial history and racially polarized voting. The district court clearly erred in ignoring or dismissing this historical background evidence, all of which supports a finding of discriminatory intent.

In 2008, Barack Obama narrowly won North Carolina in the presidential election. But in 2010, Republicans captured both houses of the legislature, and two years later McCrory defeated Lieutenant Governor Walter Dalton, as Mitt Romney edged Obama. The GOP undertook a program of conservative reforms, overturning a tradition of bipartisan moderation in the state. Among those changes was the voting law. While a bill had been under consideration, the Shelby County decision led state Senator Tom Apodaca to comment, “Now we can go with the full bill.” Though commonly referred to as a voter-ID law, similar to those passed or considered in other states, many advocates saw the other provisions as equally or more important.

In the end, it was Schroeder’s lengthy work on the case—a nearly 500-page opinion, plus 25,000 pages of record—that seemed decisive in the circuit-court decision. The panel of judges ruled that there was so much information in the record that they did not need to remand the case to the district court, and could determine that Schroeder made an erroneous factual finding on their own.

For example, the circuit-court decision makes much of the fact that legislators requested relevant data before passing the bill.

“Before enacting that law, the legislature requested data on the use, by race, of a number of voting practices. Upon receipt of the race data, the General Assembly enacted legislation that restricted voting and registration in five different ways, all of which disproportionately affected African Americans,” Motz wrote. “Although the new provisions target African Americans with almost surgical precision, they constitute inapt remedies for the problems assertedly justifying them and, in fact, impose cures for problems that did not exist.”

For example, the voter-ID law was both “too restrictive and not restrictive enough.” The circuit court found that the law harmed African American participation, but did little to combat fraud, the stated purpose, because fraud was more common in mail-in absentee voting, which was not affected.

The decision is a huge win for civil-rights advocates, who have argued in cases around the nation that voter-ID laws and other similar truncations are fighting a problem that does not exist—there is minimal evidence of voting fraud, despite insistence that such laws are essential to maintaining the sanctity of the vote—and are in fact designed to limit turnout among traditionally Democratic voters, and therefore help elect Republicans. (On occasion, voter-ID advocates trip up and say the same publicly.)

Because North Carolina’s law was among the nation’s most sweeping, and because it came so quickly after Shelby County, it has been watched as a bellwether for voting-rights cases nationwide. A favorable outcome for the state would likely embolden other conservative states to undertake similar overhauls, while a negative one would force them to take another tack, and encourage voting advocates.

Plaintiffs always expected to have a tougher hearing from Schroeder, a George W. Bush appointee, than from the Fourth Circuit, which is stocked with Obama appointees. Motz was appointed by Bill Clinton, while the other two judges on the panel, James Wynn Jr. and Henry Floyd, are Obama appointees. Many voting-law experts expect the final decision in the case to be rendered by the Supreme Court. The state is likely to appeal the decision. While the justices would be unlikely to render a decision before the November election, the state could request an injunction to keep the law in place as is.

“We are beyond happy that the Fourth Circuit Court of Appeals exposed for the world to see the racist intent of the extremist element of our government in North Carolina,” the Reverend William Barber II, president of the N.C. NAACP, said on a press call Friday afternoon. “The ruling is a people’s victory, and it is a vicotry that sends a message to the nation.”

Conservative groups, meanwhile, blasted the law. J. Christian Adams, who is president of the Public Interest Legal Foundation and a longtime voter-ID advocate, criticized the panel of judges for overreaching.

“Normally, appeals courts remand to trial courts to review the evidence with the guidance of the appeals court. The Fourth Circuit undertook the job of a trial court and the integrity of the upcoming election is worse off because of it,” Adams said in a statement. “This case was brought to extract partisan advantage using the Voting Rights Act and sadly the plaintiffs were successful in turning that important civil rights law into a political weapon.”

McCrory criticized the ruling on Facebook and suggested the state might seek to appeal the ruling or have it stayed. “Three Democrat judges are undermining the integrity of our elections while also maligning our state. We will immediately appeal their decision to strike down our voter ID law and also review other potential options,” he wrote.

Jay DeLancy, who leads the Voter Integrity Project, which seeks to find and prevent voter fraud, also criticized the decision.

“Today’s 4th Circuit decision makes it easier for criminal enterprises to exploit North Carolina’s fraud-friendly election laws,” he wrote in a statement. “The court scoffed at the heartfelt concern for election integrity; and instead, demanded further proof that vote fraud exists before they will allow preventative laws to survive. To that we say, be careful what you ask for!”

If the law is not in effect in November, it could have a major impact. McCrory is locked in a tight reelection race against Democrat Roy Cooper. Senator Richard Burr is expected to face a tight battle to hold his seat against Democrat Deborah Ross. And Hillary Clinton’s campaign has targeted the Old North State as a key swing state, hoping that a win here would block any path to victory for Donald Trump.