Just hours before Robert James Campbell was scheduled to die from lethal injection, a federal appeals court announced that the execution would be halted due to Campbell’s “intellectual disability.”

The U.S. Court of Appeals for the Fifth Circuit granted the stay  Tuesday afternoon, not long before Campbell was sentenced to be killed by lethal injection in Huntsville, Tex.

“Because of the unique circumstances of this case, Campbell and his attorneys have not had a fair opportunity to develop Campbell’s claim of ineligibility for the death penalty,” the opinion read. “In light of the evidence we have been shown, we believe that Campbell must be given such an opportunity.”

You can read the opinion here (or scroll to the bottom of the post, where it is embedded).

Campbell was sentenced to death in 1992 for murdering Alexandra Rendon, a 20-year-old bank teller, the previous year. She was abducted by Campbell and an accomplice while getting gas and was robbed and raped before Campbell shot and killed her.

“I’m happy,” Campbell said of the stay, according to a spokesman for the Texas prisons system. “The Lord prevailed.”

Members of Rendon’s family were gathered in an administrative building for an orientation meeting preparing them for the execution when they were told that the execution had been stayed.

“It’s heartbreaking, heart-sinking,” Israel Santana, Rendon’s cousin, said in a phone conversation with The Post. “My entire family is just physically and emotionally drained. It’s really rough.”

Santana says he still has faith that the execution will happen at some point.

“It’s heart-sinking that everybody’s worried about what they say is a cruel and unusual sentence for Robert Campbell, but they’re forgetting why they’re even here, what started this whole thing,” Santana said.

Meanwhile, for relatives of Campbell, the stay provided relief. Moments after the news emerged, Campbell’s sister pulled into a parking lot across the street from the penitentiary and jumped out of the car, laughing and smiling with multiple friends.

“We are excited,” Terri Brooks-Bridges said. “God is good, God is good!”

She said that her brother had maintained a positive attitude right up until the news of his stay came.

“We were worried, but we had faith,” she said. “Matter of fact, Robert had more faith than we did.”

Death penalty opponents cheered the move, which halted what would have been the eighth execution in Texas and the 21st execution in the country so far this year.

“Any time that an execution is delayed, a life is saved and we live to fight another day,” said the Rev. Jeff Hood of Denton, Tex., who is on the board of directors for the Texas Coalition to Abolish the Death Penalty.

Attorneys for Campbell had utilized multiple routes in arguing for a stay. They cited his mental impairment, calling it “an outrage” that the state hadn’t properly considered that factor. In addition, they filed an appeal and stay motion with the U.S. Supreme Court on Tuesday, owing to the secrecy surrounding the source of the drugs that would have been used in the execution.

This argument, which came in the wake of the botched execution in Oklahoma, was ultimately not necessary, as the stay was granted from the circuit court.

“The Fifth Circuit’s decision today creates an opportunity for Texas to rise above its past mistakes and seek a resolution of this matter that will better serve the interests of all parties and the public,” Robert C. Owen, an attorney for Campbell, said in a statement. “Mr. Campbell has been fully evaluated by a highly qualified psychologist … who confirms he is a person with mental retardation.”

The Supreme Court ruled in 2002 that executing the mentally retarded violated the Constitution’s prohibition against cruel and unusual punishment.

This post has been updated. Karen Brooks Harper in Huntsville, Tex., contributed to this report.