A seven-year legal battle over Texas’s legislative maps largely ended on Monday, as the Supreme Court rejected almost all claims that Republican lawmakers in the state had drawn electoral districts to intentionally dilute minority voters’ influence—otherwise known as racial gerrymandering. The decision in Abbott v. Perez rounds out a string of defeats at the high court this term for voting-rights advocates. It also vindicates Texas Republicans’ strategy to shield a discriminatory electoral map from judicial correction.

In 2011, following the 2010 census, Texas lawmakers redrew the state’s legislative and congressional districts. A group of black and Hispanic Texans quickly mounted a legal challenge to the new map, arguing that the state’s Republican lawmakers had engaged in racial gerrymandering by redrawing districts to bolster white Texans’ voting power. With the 2012 election imminent, a federal court made minor alterations to the 2011 map for use in that year’s races.

When Texas Republicans returned to the legislature in 2013, they adopted the court’s interim maps as the permanent maps, with only a few alterations. After the courts later ruled that the 2011 maps—including the 35th Congressional District, shown in the image above—had been drawn with discriminatory intent, the state argued that the 2013 maps weren’t affected because they had been largely drawn by the courts themselves. In effect, Republicans had laundered a racially gerrymandered map through the judicial system.

The lower courts weren’t fooled. A three-judge panel ruled last year that the 2011 map’s “taint” hadn’t actually been removed from the 2013 map, despite the state’s claims. But Justice Samuel Alito, writing for the majority on Monday, said the lower court had committed a “fundamental legal error” by placing the burden to prove the maps’ constitutionality on the state instead of the plaintiffs who brought the lawsuit.

“The 2013 Legislature was not obligated to show that it had ‘cured’ the unlawful intent that the court attributed to the 2011 Legislature,” he wrote. “When the congressional and state legislative districts are reviewed under the proper legal standards, all but one of them, we conclude, are lawful.” Justices John Roberts, Anthony Kennedy, Clarence Thomas, and Neil Gorsuch joined his opinion.