A majority of the full U.S. 5th Circuit Court of Appeals ruled Wednesday that the heavily litigated and controversial Texas voter ID law does have the effect of discriminating against minority voters, and ordered the state to devise a remedy to that problem before the November elections.

“We conclude that the district court did not clearly err in determining that SB 14 has a discriminatory effect on minorities’ voting rights in violation of Section 2 of the Voting Rights Act,” the court majority wrote.

The unexpected ruling against the Republican-backed voter ID law by the conservative appeals court came as it faced a Supreme-Court-imposed deadline of Wednesday to rule in the case.

The ruling was not a complete victory for voting rights activists. A second basis for challenging the law – that its purpose is to discriminate against minority voters – was sent back to the lower court for further review. The appeals court said the additional review should wait until after the November elections.

While the appeals court struck down the law, the voter ID requirement in Texas does not appear to be going away. Rather, the appeals court ordered the lower court to devise a remedy that preserves the intention of the voter ID law–to protect against voter fraud, which experts maintain is exceedingly rare–while mitigating the discriminatory effects on people who cannot readily obtain the ID required under the law.

“In light of the impending election, we order the district court to file its order regarding the proper discriminatory effect remedy as soon as possible,” the court said in the majority decision. “The parties have expressed a willingness to work cooperatively with the district court to provide a prompt resolution of this matter, and we urge them to do so to avoid election eve uncertainties and emergencies.”

The appeals court did not say so explicitly but seemed open to a solution along the lines of recent carve-outs in Wisconsin’s voter ID law that allows people unable to obtain voter ID easily to cast their vote anyway.

“In sum, the district court’s immediate responsibility is to ensure the implementation of an interim remedy for SB 14’s discriminatory effect that disrupts voter identification rules for the 2016 election season as little as possible, yet eliminates the Section 2 discriminatory effect violation,” the court ruled.

Read the full opinion: