Virginia Gov. Ralph Northam (D) delivers his State of the Commonwealth address in January during a joint session of the legislature in Richmond. (Steve Helber/Associated Press)

The Supreme Court ruled Monday that Virginia’s House Republicans did not have the legal right to challenge a decision that some of Virginia’s legislative districts were racially gerrymandered, which means fall elections will take place in districts more favorable to Democrats.

All 140 seats in the legislature are on the ballot, and the GOP holds a three-seat edge in the House (51 to 48) and a bare majority in the Senate (20 to 19), with one vacant seat in each chamber.

Democrats have been hoping that a wave of successes in recent Virginia elections will move them into control of the legislature for the first time since 1995. The party in charge in 2021 will oversee the next statewide re­districting effort, following next year’s census — potentially cementing an advantage in future elections.

The 5-to-4 decision did not shed light on how courts should consider claims of racial gerrymandering, but rather who has the right to sue. The court is considering potentially more groundbreaking cases about partisan gerrymandering, in maps drawn by Republicans in North Carolina and Democrats in Maryland.

The court has never found that politics have so infected a redistricting process that voters’ constitutional rights were violated. Its decision in those cases will come before the end of the month.

In the Virginia case decided Monday, Justice Ruth Bader Ginsburg wrote for the majority that House Republican leaders could not challenge the court ruling after Attorney General Mark R. Herring (D) acquiesced.

“The State of Virginia would rather stop than fight on,” she wrote. “One House of its bicameral legislature cannot alone continue the litigation against the will of its partners in the legislative process.”

Ginsburg was joined in an unusual alignment by fellow liberal Justices Sonia Sotomayor and Elena Kagan, as well as conservatives Clarence Thomas and Neil M. Gorsuch. Because Thomas is the senior justice in that coalition, he would have assigned the opinion to Ginsburg.

Justice Samuel A. Alito Jr. dissented, saying he saw no support “for the proposition that Virginia law bars the House from defending, in its own right, the constitutionality of a districting plan.” He was joined by fellow conservatives Chief Justice John G. Roberts Jr. and Justice Brett M. Kavanaugh, as well as liberal Justice Stephen G. Breyer.

The districts have been subject to legal challenges ever since they were drawn in 2011. Republicans controlled the House of Delegates at the time and Democrats the state Senate. Under a deal, Republicans drew the map for the House, and Democrats drew the one for the Senate without interference from the other chamber.

The House map had the support of the Legislative Black Caucus and was approved by the Justice Department under President Barack Obama.

But courts eventually found that legislators had placed too much emphasis on race in drawing the lines, and a panel of federal judges found that 11 House districts were improper. The House declined the court’s offer to draw new maps, and the court hired an expert to do the work.

It realigned 26 House districts as it remedied the 11 under court order. Republican incumbents in six of those districts will find it more difficult to defend their seats against Democratic challengers this November, according to an analysis by the nonpartisan Virginia Public Access Project. Primaries were held last week in the new districts.

Not surprisingly, Virginia Democrats and Republicans had opposite reactions.

“Today’s Supreme Court ruling is a victory for democracy and voting rights in our Commonwealth,” Gov. Ralph Northam (D) said in a written statement. “When we corrected racially gerrymandered districts earlier this year, we righted a wrong — as I have always said, voters should choose their representatives, not the other way around.”

Herring, who had argued that the decision on whether to appeal the gerrymandering decision was his alone to make, called it a “big win for democracy.”

“It’s unfortunate that House Republicans wasted millions of taxpayer dollars and months of litigation in a futile effort to protect racially gerrymandered districts, but the good news is that this fall’s elections will take place in constitutionally drawn districts,” Herring said in a statement.

Republicans said both men were hypocritical; Northam and Herring had voted for the original redistricting plans as members of the state Senate.

House Speaker Kirk Cox (R-Colonial Heights), whose own district was reconfigured by the decision, said he was “disappointed” with the ruling.

“The court’s opinion today ends a disappointing saga of orchestrated attacks against the constitutionally enacted redistricting plan,” Cox said in a statement. “A shadowy organization funded by out-of-state interests has cost the taxpayers millions to overturn a legislative map that passed in 2011 that passed with an overwhelming majority.”

He scolded Herring for declining to defend the maps.

Adam Kincaid, executive director of the National Republican Redistricting Trust, said the decision will have effects beyond Virginia.

“The broader implications of this holding will reverberate across the states, touching virtually every area of politically charged law,” he said in a statement. “The Court has sown to the winds of expediency and will reap a whirlwind of partisan mischief as state attorneys general pick and choose which laws they will defend and which they will disregard on behalf of those plaintiffs with which they are politically or ideologically aligned.”

The Trump administration filed a friend-of-the-court brief that essentially agreed with Herring, saying the House of Delegates as an institution has no inherent interest in the shape of its districts or who gets elected to represent them.

Ginsburg agreed. “The House does not select its own members,” she wrote. “Instead, it is a representative body composed of members chosen by the people. Changes to its membership brought about by the voting public thus inflict no cognizable injury on the House.”

To which Alito replied: “Really?”

“It seems obvious that any group consisting of members who must work together to achieve the group’s aims has a keen interest in the identity of its members, and it follows that the group also has a strong interest in how its members are selected,” he wrote.

“Does a string quartet have an interest in the identity of its cellist? Does a basketball team have an interest in the identity of its point guard?”

The case is Virginia House of Delegates v. Bethune-Hill.