Editor's note: This story has been updated throughout

Federal judges invalidated two Texas congressional districts Tuesday, ruling that they must be fixed by either the Legislature or a federal court.

A three-judge panel in San Antonio unanimously ruled that Congressional Districts 27 and 35 violate the U.S. Constitution and the federal Voting Rights Act.

The judges found that Hispanic voters in Congressional District 27, represented by U.S. Rep. Blake Farenthold, R-Corpus Christi, were "intentionally deprived of their opportunity to elect a candidate of their choice." Congressional District 35 — a Central Texas district represented by Democrat Lloyd Doggett of Austin — was deemed "an impermissible racial gerrymander" because lawmakers illegally used race as the predominant factor in drawing it, the judges wrote.

The Texas Tribune thanks its sponsors. Become one .

The 107-page ruling — the latest chapter of a six-year court battle over how Texas lawmakers drew political maps — sets up a scramble to redraw the districts in time for the 2018 elections. The court ruled only on the current congressional map, leaving legal challenges to the state House map unanswered.

The court ordered the Texas Attorney General’s Office to indicate within three business days whether the Texas Legislature would take up redistricting to fix those violations — although Republicans in Austin had previously expressed no appetite to undertake a special session devoted to redistricting.

Otherwise, the state and its legal foes will head back to court on Sept. 5 to begin re-drawing the congressional map.

That could shake up other congressional races when the boundaries are changed, though the court has asked the parties to consult with experts to “minimize the effect on adjoining districts.”

Before Tuesday’s decision, the judges had already ruled that the Texas Legislature sought to weaken the strength of Latino and black voters while drawing state House and congressional districts in 2011, immediately following the 2010 U.S. Census. But the 2011 maps never actually took effect.

Amid legal wrangling over the Legislature’s maps, the court drew temporary maps ahead of the 2012 elections. Texas lawmakers formally adopted those maps in 2013 and have used them for the past three election cycles.

The Texas Tribune thanks its sponsors. Become one .

On Tuesday, the court ruled that the intentional discrimination behind the 2011 maps carried over into the 2013 map in places like CD-35 and CD-27, where the district boundaries were unchanged “because the Legislature engaged in no deliberative process to remove any such taint and intentionally furthered and continued the existing discrimination in the plans.”

The state argued in court that lawmakers could not have sought to discriminate because they adopted the court-drawn map. But the judges on Tuesday blasted the state for employing that strategy instead of “trying to cleanse the plans of continuing discriminatory intent or legal defect.”

They specifically took issue with the state’s argument that it could not be penalized for its past discrimination.

“This strategy is discriminatory at its heart and should not insulate either plan from review,” the court wrote.

The state did score a win on Congressional District 23 — represented by Republican Will Hurd of Helotes — which the judges ruled could be left intact. That sprawling West Texas district was previously flagged as discriminatory but had been modified by the court since then. In Tuesday’s ruling, the judges called it a “Latino opportunity district.”

Texas Attorney General Ken Paxton expressed mixed emotions about Tuesday’s outcome.

“We appreciate that the panel ruled in favor of Texas on many issues in the case. But the portion of the ruling that went against Texas is puzzling considering the Legislature adopted the congressional map the same court itself adopted in 2012,” the Republican said in a written statement. “We look forward to asking the Supreme Court to decide whether Texas had discriminatory intent when relying on the district court.”

Minority and civil rights groups suing the state celebrated the ruling as a win for voters who they say were forced to cast votes under unconstitutional maps.

The Texas Tribune thanks its sponsors. Become one .

“Intentional discrimination is a bad habit for the Texas Legislature,” said Democratic state Rep. Rafael Anchia, chairman of the Mexican American Legislative Caucus. “With the seventh ruling of intentional discrimination since 2011, a federal court confirmed today that Texas congressional maps remain unconstitutional.”

The ruling comes as state Republicans continue to grapple with the state’s rapidly changing demographics.

Texas is becoming less white each day, creating headaches for the party that currently dominates state government as minorities — particularly Hispanic and black voters — overwhelmingly support Democrats in elections.

State leaders’ attempt to confront that growth in their latest round of redistricting landed them in legal trouble.

Texas has not disputed that it practiced an extreme version of gerrymandering in 2011. But the state’s lawyers have argued that partisanship, not race, motivated them.

But in Texas and elsewhere, race and partisanship are often intertwined, and opponents of the maps successfully argued — in a few cases, at least — that lawmakers advanced their party’s interests by improperly looking to race.

It’s unclear what Tuesday’s ruling will mean for the future of federal oversight in crafting Texas election laws.

For decades under the Voting Rights Act, Texas was on a list of states and localities needing the federal government’s permission to change election laws, a safeguard for minority voting rights called preclearance. The U.S. Supreme Court wiped clean the list in 2013 and lifted federal oversight for Texas and other jurisdictions, noting that conditions for minority voters had "dramatically improved."

But the ruling left open the possibility that future, purposeful discrimination could mean a return to preclearance.