On Wednesday, the state of Texas is scheduled to kill Travis Trevino Runnels, after the Texas Court of Criminal Appeals rejected a last-ditch motion to postpone his execution. Runnels will be the ninth person executed in Texas this year, and the third this year whose trial was tainted by the misleading testimony of A.P. Merillat, who for years offered prosecutors a helping hand in death penalty cases across Texas. In two other death penalty cases, Merillat’s misleading testimony role led the Court of Criminal Appeals to toss out the sentences. But Runnels is running out of time.

Runnels’s guilt is not in doubt. While serving a seventy-year sentence for aggravated robbery in a prison in Amarillo, he cut the throat of supervisor Stanley A. Wiley. In 2005, Runnels pleaded guilty to the crime of capital murder. (His supporters say that he is repentant, and that his years on death row have changed him.) What’s at question instead is how Runnels came to be on death row, and whether Merillat’s testimony during Runnels’s sentencing at his 2005 trial was so egregiously in error that it warrants further scrutiny.

At the time, Merillat, who now works for the Montgomery County district attorney’s office, was an investigator with the Special Prosecution Unit, an agency that investigates crimes committed in state prisons. He came to face to face with the worst of the prison system: gruesome murders, gang violence, hardened criminals. In the small world of the death penalty in Texas, he was something of a minor celebrity—an author and college professor who looked straight out of central casting as an East Texas cop, and who spoke gravely about the evils that men did inside bars.

When it came time for jurors to decide whether to sentence a person to death or to life in prison, Merillat would tell the jury that state prisons were incapable of safely holding dangerous men. “Merillat’s testimony was just bullshit,” said Frank Aubuchon, who worked for the Texas Department of Criminal Justice for 26 years. “What Merillat would do for years, when he got on the stand, I’ve seen it described by someone else as throwing a skunk in the jury box. His job was to scare the jury into killing the guy. And that’s what he did, for years.”

In Texas, you have to do more than just prove someone is guilty of a crime like capital murder to make them eligible for death row. Prosecutors also have to prove that defendants pose a “future danger” to the public if released, or to inmates and guards if they’re returned to prison. In the past, prosecutors relied on psychiatrists to testify that offenders would kill again if given the chance. One such expert witness was the psychiatrist Dr. James Grigson, whose eagerness earned him the nickname “Dr. Death.” Grigson was repeatedly reprimanded by the American Psychiatric Association, and his colleagues considered him a quack. When he and other experts were discredited, prosecutors working on cases involving prisons began relying instead on testimony from officials with knowledge of the prison system, people like A.P. Merillat.

Merillat told me he never claimed that specific defendants like Runnels would be a “future danger”—indeed, he says he often didn’t know much about them. In the Runnels trial, Merillat testified that inmates convicted of capital murder were “automatically” placed in mid-level security conditions, sharing cells with people convicted of minor crimes, when in reality, according to Texas Department of Criminal Justice guidelines at the time, he would not have been “automatically” placed anywhere—but instead assessed by a panel extremely unlikely to have put Runnels in anything less than maximum-security conditions, where he would have had minimal contact with other human beings.

After that testimony, which was never challenged by Runnels’s defense attorney, the jury decided that Runnels would pose a threat to others and sentenced him to death. Merillat offered similar testimony in at least fifteen other death penalty cases, even writing a book titled Future Danger? that was published in three editions and once made available free to felony prosecutors by a grant from the Texas Court of Criminal Appeals.

In posts from the time on the Texas District and County Attorneys Association website, Merillat expressed indignation and disgust at experts for the defense, whom he accused of appearing solely for money. (Expert witnesses are sometimes paid for their time.) But in 2010 and again in 2012, the Texas Court of Criminal Appeals voided two death sentences because of Merillat’s testimony, effectively ending his involvement in death penalty cases.

In both cases, the court ruled that Merillat had given materially inaccurate evidence about how inmates would have been handled if sent back to prison, using an outdated interpretation of TDCJ rules. The court indicted both Merillat and the prosecutors who put him on the stand, writing in the 2012 case of Manuel Velez that “both Merillat and the state … knew or should have known that Merillat’s testimony” was “false.” The damage Merillat’s testimony caused to the integrity of the trial, the court’s opinion said, was increased by Merillat’s “extensive credentials.”

The fact that Merillat offered this kind of testimony in so many cases gave hope to others on death row. But this year has already seen the execution of two men—Billie Coble and Robert Sparks—who were sentenced to death in trials where Merillat offered testimony. Merillat’s testimony played a similar role in many cases, but the way Texas courts have handled the aftermath of them can seem arbitrary and capricious—sometimes acknowledging it, sometimes downplaying it, and sometimes declining to consider it for questionably determined procedural reasons.

In the Coble and Sparks cases, the Court of Criminal Appeals ruled that Merillat’s account was countered effectively by defense lawyers in open court or was less likely to have been crucial to the sentence. Anticipating the court’s position, Runnels’s new defense team argued in a motion filed in September that Merillat’s testimony was central to Runnels’s sentence and egregiously flawed, in a way that merits a stay of execution.

But the court rejected the motion on purely procedural grounds, making no statement about Merillat’s role. Nor has the state, in its response to Runnels’s motion, attempted to defend what Merillat said. “The state is not even denying that Merillat testified falsely,” said Mark Pickett, a lawyer on Runnels’s defense team. “They aren’t denying it because they know they can’t deny it. The best thing they could come up with is that maybe Travis’s counsel should have found the claim a few years ago. People complain about criminals getting off on technicalities, but that’s what this is: the state put on a lying witness, whether they knew it or not. And now they want everyone to ignore it because it took people too long to notice what they did.”

Merillat stands by his testimony and argues that the Court of Criminal Appeals unfairly impugned his reputation. When he testified, he said, it was just as an informational resource. “Sometimes I wouldn’t even know anything about the crime,” Merillat told me. “It didn’t affect me in my job if he got life, death, or anything else, not guilty. It was nothing to do with me or my office. I just came to talk about the levels of violence and the opportunities to commit criminal acts when a person is sent to the penitentiary.” Merillat says he “thought that it was the right thing to do to inform juries of the truth of the classification system, because they weren’t being told the truth.”

The “classification system” refers to the way prison officials assign new inmates to various security levels based on factors that can include the inmate’s previous history in prison and the nature of their crime. Merillat told jurors that the classification system was inadequate and prison safeguards were faulty—that violent criminals regularly ended up in the general population free to cause havoc.

On the stand in the Runnels case, Merillat testified that capital murderers like Runnels were held, as a matter of course, in risky conditions. “A capital murderer,” Merillat said, “when he comes in to the penitentiary, will automatically be classified as G-3.” There were five levels in the classification system, from G-1 to G-5, he explained to the jury, G-1 being relatively permissive and G-5 being the most restrictive.

Merillat spoke in generalities, talking about a hypothetical capital murderer, rather than Runnels specifically. But his warnings about what happens to such inmates was dire. “He could have a cellmate who happens to be a G-2 or a G-1 inmate. He could be housed with a DWI offender, for example.”

The message was clear: Runnels, who had already killed one man in prison, would be able to kill again if sent back to prison. He would be “automatically” put in a cell with, potentially, first-time offenders for nonviolent crimes. Wouldn’t prison officials take into account Runnels’s prior behavior? “If he had prior convictions … the prison is not going to look at those previous convictions,” Merillat testified.

Merillat’s testimony about the prison classification system went more or less unchallenged by Runnels’s defense team—even though there was at least one significant clue that Merillat’s expertise on prison classification rules was suspect. Asked by the prosecutor what the “G” in the classification scheme stood for, Merillat replied: “I have no idea what the letter ‘G’ stands for. It’s just a letter the prison issued for that classification.” (The “G” stands for “General,” as in general population, which is plastered all over TCDJ’s rulebook from the time.)

Aubuchon testified in a number of cases where Merillat once offered his testimony on appeal. “He wasn’t a classification expert, but he tried to pawn himself off as one,” Aubuchon said. In another case, Aubuchon says, Merillat told the court he’d read the classification guide—a complicated and lengthy document. “Well, I’ve read the pilot operating handbook for a Douglas DC-3,” Aubuchon says. “Who wants to go flying with me today?”

But beyond that, Runnels would never have ended up in G-3 custody, Aubuchon says. “He would have gone into administrative segregation,” Aubuchon said. Administrative segregation entails solitary confinement for 22 hours a day, no contact with other inmates and very limited, structured interaction with prison guards.

One of the quickest ways for an inmate to land in ad seg is if his “presence in the general population presents a risk of harm to other offenders or staff members,” he said. “Well, Travis cut an employee’s throat,” he said. That’s pretty clear, Aubuchon said. To the idea that Runnels would have ended up in gen pop, Aubuchon flatly declares that “there is no way in God’s green earth that that would have ever happened.”

Aubuchon describes Merillat as “a stranger to the truth” who testified with more confidence about how prison classification worked than he had a right to. “I hope he’s enjoying his retirement,” Aubuchon said. Informed that Merillat is currently working as an investigator for the Montgomery County DA’s office, Aubuchon replies: “Well, that’s scary.”

Today, Merillat says he’s the victim of a campaign to smear his reputation. “Since I was called so many times to [testify],” he said, “I became an enemy of the ACLU, the defense [lawyers’] association.” His role as an investigator in the wider prison system led him to have a greater awareness of the reality of Texas prisons than some TDCJ employees might have, he said. (However, Merillat did not restrict his testimony to his experiences alone.) “Had I been a liar or a perjurer, I would not have been able to keep my peace officer’s license for 42 years now, and I would certainly not have this job [with the Montgomery County DA].” He adds: “I have an immaculate record except for the false accusations made against me.”

The Court of Criminal Appeals’ decision to reject Runnels’s motion on procedural grounds means that his lawyers will have to seek relief from the U.S. Supreme Court—or hope that he’s given clemency. Barring a last-minute victory, Runnels will be executed on Wednesday. At times, Merillat seems conflicted about his role in the case, perhaps even willing to entertain serious doubts about whether Runnels’s death sentence was just.

“If it’s somebody who needs to be let off of death row, then let it happen. And if I should go to death row on behalf of somebody because I did something wrong, I’m willing to go do that myself,” he said.

Other times, he seems unwilling to give his critics any quarter—and offers a belief that the whole matter is out of his hands. “I trust God to work his will,” he says. “I have no reason to be ashamed of anything I did throughout my career.”