WASHINGTON — The Supreme Court on Thursday struck down Republican-drawn congressional districts in Alabama that civil rights activists say discriminated against Black voters in a surprise reaffirmation of the landmark Voting Rights Act.

The court in a 5-4 vote ruled against Alabama, meaning the map of the seven congressional districts, which heavily favors Republicans, will now be redrawn. Chief Justice John Roberts and Justice Brett Kavanaugh, both conservatives, joined the court’s three liberals in the majority.

In doing so, the court — which has a 6-3 conservative majority — turned away the state’s effort to make it harder to remedy concerns raised by civil rights advocates that the power of Black voters in states like Alabama is being diluted by dividing voters into districts where white voters dominate.

In the ruling, Roberts, writing for the majority, said a lower court had correctly concluded that the congressional map violated the voting rights law.

In 2013, Roberts authored a ruling that gutted a separate, important provision of the Voting Rights Act and has long argued that various government efforts to address historic racial discrimination are problematic and may exacerbate the situation.

He wrote in Thursday’s ruling that there are genuine fears that the Voting Rights Act “may impermissibly elevate race in the allocation of political power” and that the Alabama ruling “does not diminish or disregard those concerns.”

The court instead “simply holds that a faithful application of our precedents and a fair reading of the record before us do not bear them out here,” Roberts added.

As such, the court left open future challenges to the law, with Kavanaugh writing in a separate opinion that his vote did not rule out challenges to Section 2 based on whether there is a time at which the 1965 law’s authorization of the consideration of race in redistricting is no longer justified.

Civil rights groups and their supporters, including President Joe Biden, reveled in a largely unexpected victory.

“Today’s decision confirms the basic principle that voting practices should not discriminate on account of race, but our work is not done,” Biden said in a statement. He renewed calls for Congress to pass new voting rights legislation.

NAACP President Derrick Johnson applauded the court for rebuffing what he characterized as an effort to suppress the Black vote.

“This decision is a victory for Black America and a triumph for our democracy,” he said. But, he added, “this fight is far from over.”

Despite the ruling, Alabama Attorney General Steve Marshall vowed to continue the battle over the state’s maps.

“Although the majority’s decision is disappointing, this case is not over,” he said in a brief statement.

The two consolidated cases arose from litigation over the new congressional district map that was drawn by the Republican-controlled Alabama Legislature after the 2020 census. The challengers, including individual voters and the Alabama State Conference of the NAACP, said the map violated Section 2 of the Voting Rights Act by discriminating against Black voters.

The new map created one district out of seven in the state in which Black voters would likely be able to elect a candidate of their choosing. The challengers say that the state, which has a population that is more than a quarter Black, should have two such districts and provided evidence that such a district could be drawn.

A lower court agreed in a ruling last January, saying that under Supreme Court precedent, the plaintiffs had shown that Alabama’s Black population was both large enough and sufficiently compact for there to be a second majority-Black district. The court ordered a new map to be drawn, but the state’s Republican attorney general, Steve Marshall, turned to the Supreme Court, which put the litigation on hold and agreed to hear the case.

Four conservative justices, led by Justice Clarence Thomas, dissented in Thursday’s ruling.

Thomas wrote that his preferred outcome “would not require the federal judiciary to decide the correct racial apportionment of Alabama’s congressional seats.”

He added that under the approach taken by the lower court, Section 2 of the Voting Rights Act “is nothing more than a racial entitlement to roughly proportional control of elective offices … wherever different racial groups consistently prefer different candidates.”

Last year, the Supreme Court was divided 5-4 in allowing the Republican-drawn map to be used in November’s election, with Roberts joining the court’s three liberals in dissent. Kavanaugh indicated then that his vote to allow the map to be used was based on the lower court decision being issued too close to the election.

Republicans won six of the seven seats in the election, while Democrats won the majority-Black district. With Black voters more likely to vote for Democrats, Democrats might have picked up an additional seat if a new map had been adopted.

The Alabama case was one of several in which the Supreme Court’s decisions may have contributed to Republicans winning their fragile majority in the House of Representatives.

Alabama argued that the lower court put too much emphasis on race in reaching its conclusions. Marshall said in court papers that the fact that the challengers were able to show using computer-generated maps that it was possible to draw a second majority-Black district was not sufficient evidence that the state’s actions were discriminatory. He cited other traditional “race-neutral” map-drawing factors that take into account issues such as regional culture and identity, as well as the requirement that districts have similar-sized populations.

Richard Pildes, an election law expert at New York University School of Law, said the ruling is “more significant … going forward than simply a reaffirmation of the status quo.”

That’s because the court effectively endorsed the use of computer-generated maps in challenging districts. New technology makes it easier to find maps that could potentially be challenged under the Voting Rights Act, he added.

The Supreme Court has in two cases over the last decade weakened the Voting Rights Act, beginning in 2013 when it gutted a key provision of the law that allowed for federal oversight of election law changes in certain states. In a 2021 ruling arising from Arizona, the court made it more difficult to bring cases under Section 2.

The case is one of three the court is hearing in the current term in which conservative lawyers are pushing what they call race-neutral arguments favored on the right as a way to remedy race discrimination. In the others, the court could end affirmative action in college admissions and strike down part of a law that gives preference to Native Americans seeking to adopt Native American children.

The court is also considering another significant election-related dispute in its current term, with the court set to rule on a Republican effort to curb the ability of state courts to enforce state constitutional provisions in federal elections. That ruling, due before the end of this month, could make it easier for Republican legislatures to restrict voting rights.

CORRECTION (June 8, 2023, 1:41 p.m. ET): A previous version of this article misstated the year of a lower court decision. It was January 2022, not this past January.