Charles Flores, a Texas death row inmate who was scheduled to be executed next week June 2, was granted a stay of execution late Friday afternoon.

The Texas Court of Criminal Appeals stayed Flores’ execution date and sent his case back to the trial court for a hearing based on his claim that improper hypnosis was used on the main eyewitness in his murder trial.

As Fusion reported earlier this month, Flores was convicted for the 1998 murder of Elizabeth “Betty” Black in a Dallas suburb. A jury sentenced him to death the following year even though prosecutors presented no physical evidence linking him to the crime, and the only witness who saw him at the scene, Jill Barganier, was hypnotized by police.

As part of Flores’ final appeal, which was filed last week, psychology professor Steven Lynn said in an affidavit that recent research shows the hypnosis could have made Barganier create false memories. “Clearly, the techniques that were used to refresh Ms. Bargainer’s memory would be eschewed today by anyone at all familiar with the extant research on hypnosis and memory,” Lynn wrote.

That hypnosis was the crux of the appeals court’s ruling. The court approved his application for a writ of habeas corpus by essentially finding reason to believe a reasonable juror may not have convicted him if they had heard evidence like Lynn’s testimony.

Now, the trial court in Flores’ case will hold a hearing specifically on the hypnosis issue and the eyewitness identification. If Flores’ lawyers can show by a preponderance of the evidence that a jury would acquit him today after hearing new scientific evidence, it would lead to a brand new trial for Flores, more than 17 years after he was convicted.

“We’re ecstatic for Charles right now,” said Gregory Gardner, one of Flores’ attorneys. “This hypnosis was always very troubling from the beginning… and we’re thrilled that now the Texas courts are going to take a closer look at it.”

The warden at the Polunksy Unit, the Texas death row prison where Flores is housed, is expected to notify him of the ruling later tonight.

While the appeals court focused on the hypnosis issue in its ruling, Flores also brought up other issues in his appeal—including the fact that his white co-defendant received a much shorter sentence than he did and is currently out of prison on parole.

Two of the nine judges on the appeals court, which is the highest court in Texas that hears criminal cases, dissented from granting a stay. Only one of the judges who supported Flores’ application, David Newell, wrote an opinion explaining his thinking.

“Eyewitness misidentification is the leading cause of wrongful convictions across the country,” Newell wrote. “We may ultimately grant relief. We may ultimately deny relief. But either way, given the subject matter, by granting a stay this Court acknowledges that whatever we do, we owe a clear explanation for our decision to the citizens of Texas.”

Here’s the full ruling from the court: