This story has been updated.

When Texas tried to kick Planned Parenthood out of the state’s Medicaid program based on “sting" videos produced by undercover antiabortion activists, a federal judge in Austin said the whole case sounded more as if it belonged in a “best-selling novel.”

“Yet, rather than a villain plotting to take over the world, the subject of this case is the State of Texas’s efforts to expel a group of health care providers from a social health care program for families and individuals with limited resources,” U.S. District Judge Sam Sparks wrote in February 2017.

Sparks was skeptical. Texas contended the videos showed Planned Parenthood discussing the illegal sale of fetal tissue of aborted babies, an interpretation Planned Parenthood has disputed. Sparks, in turn, said the state had not produced “even a scintilla of evidence” suggesting Planned Parenthood should be disqualified from Medicaid based on the videos.

But on Thursday, the U.S. Court of Appeals for the 5th Circuit said Sparks is the one who had it all wrong. The three-judge panel found he used the incorrect standard of review, vacating Sparks’s 2017 preliminary injunction that had blocked Texas from defunding Planned Parenthood, and remanding the case back to the district court for further review.

The ruling from the 5th Circuit effectively gives weight to the sting videos and the conclusions Texas reached based on them in a way the court hasn’t offered before. It comes one month after the Supreme Court left in place a previous ruling by the 5th Circuit in favor of Planned Parenthood. In that case, the 5th Circuit rejected Louisiana’s effort to defund the health-care provider that had been based in part on the sting videos, mostly because the state hadn’t cited the videos in writing when announcing its decision to terminate the Planned Parenthood contract and lacked other adequate reasoning. (The Supreme Court also declined to hear a similar effort from Kansas.)

But Texas did cite the videos, in a state report — and that’s the big difference.

In the opinion, Judge Edith H. Jones of the 5th Circuit criticized Sparks for being too “dismissive” of a report by the Texas Health and Human Services Commission’s Office of Inspector General that served as the basis for booting the organization from Medicaid and revoking $3.4 million in funding. The report concluded Planned Parenthood had diverged from “standards of medical ethics" based on the video footage, which was produced by the Center for Medical Progress, an antiabortion group.

Sparks had all but crumpled up that report and thrown it in the trash. He noted that the people who led the report — a lawyer and orthopedic sports-medicine surgeon — had no background in reproductive health care, questioning how they would know whether medical standards were breached. In fact, when the inspector general initially recommended Planned Parenthood be defunded, he acknowledged he had not even reviewed all eight hours of the video footage, Sparks noted. He said the state health agency offered no evidence “at all” that it took steps to authenticate the sting videos.

But Jones, an appointee of President Ronald Reagan, said Sparks was wrong to make these judgments. She said Texas’s report should have been given "deference” over the outside testimony from Planned Parenthood’s experts — regardless of Sparks’s opinions of the authors' qualifications.

“[The Office of Inspector General] is the agency that the state of Texas has empowered to investigate and penalize Medicaid program violations," Jones wrote. "The agency is in the business of saying when providers are qualified and when they are not. That the Chief Medical Officer is a surgeon—and not himself an abortion provider— does not mean that he deserves no deference when deciding whether a provider has failed to meet the medical and ethical standards the state requires.”

Planned Parenthood spokeswoman Erica Sackin said in a statement Friday that “it is completely outrageous that officials are using thoroughly discredited, fraudulent videos to try to cut women off from preventive health care, including cancer screenings, HIV testing, and birth control.”

Seth Chandler, a law professor at the University of Houston, said the ruling spells trouble for Planned Parenthood. The 5th Circuit will now require Sparks to apply a different standard of review — a much higher one, assessing this time whether Texas’s decision to defund Planned Parenthood was “arbitrary and capricious.” To rule against Texas, Chandler said, Sparks would have to find the state had virtually no good reason for its decision to terminate the contract.

The problem, Chandler said, is even if Sparks still believes based on the evidence that the sting videos are bogus, the state can likely demonstrate they were still a good enough rationale for its decision to cut ties with Planned Parenthood. The videos are largely subject to interpretation, Chandler said, but the 5th Circuit would be more likely to give Texas the benefit of the doubt.

“I think it’s going to be quite difficult for Planned Parenthood to prevail," Chandler said. "The standard the 5th Circuit has set down is one that, given the evidence and the history in this case, and a clear signal from the 5th Circuit in this case, Planned Parenthood is going to be hard-pressed to meet. The $3.4 million Planned Parenthood receives from Texas pursuant to the Medicaid program is very likely going to go away.”

Even if Sparks again rules for Planned Parenthood, Chandler said it’s clear from Jones’s ruling that the 5th Circuit isn’t inclined to do any favors for the health-care provider. Jones, in particular, has openly criticized the Supreme Court’s decision in Roe v. Wade. In this ruling, she included a graphic photo of bloody fetal tissue that came from the video footage, apparently for dramatic effect, Chandler said.

“There are some signs of hostility to abortion in that opinion," he said, “and the 5th Circuit has pretty strongly hinted how it’s going to come out.”

The case, technically, isn’t about abortion, he said. Instead, he said, it’s about whether Texas had the right to terminate a contract with a health-care provider under the Medicaid Act, and whether the provider’s patients had a private right of action to join the lawsuit.

The appeals courts are split on the latter issue, and the Supreme Court let them stay that way in declining to hear the Planned Parenthood cases in December. As The Washington Post reported previously, five regional appeals courts have ruled Medicaid recipients receiving services from Planned Parenthood had the private right of action, while one has ruled they don’t.