An appeals court has stayed the execution of a mentally ill Texas man sentenced to death for the execution of his ex-wife's parents. The stay came hours before the man's scheduled execution later on Wednesday.

Human rights groups, psychiatric groups and conservatives came together in opposition to the impending execution.

The 5th U.S. Court of Appeals granted Scott Panetti a reprieve just eight hours before his execution, according to USA Today. Panetti's lawyers had been arguing their client is too mentally impaired to be executed under the law. The court said on its ruling it needed more time to "allow us to fully consider the late-arriving and complex legal questions at issue in this matter."

Oral arguments will be scheduled and Texas' state attorney general said he would not fight the ruling. Many have called for Panetti's execution to be stayed because of his mental state, including the American Psychiatric Association.

"This has been a long saga," said Paul Appelbaum of the APA, who lobbied against the execution. "We're not at the end of the story yet. ... His behavior, best we can tell, was driven by his illness rather than a deliberate act of criminal intent."

Amnesty International had also called for a stay of execution in late November, criticizing Texas' decision to continue the execution.

"It is never too late until the lethal injection is administered. The parole board can vote for commutation. The governor can stop the execution, even without a recommendation to do so from the board. To choose to kill Scott Panetti would put down another shameful marker in the ugly history of the death penalty in the USA," said Rob Freer, USA Researcher at Amnesty International.

Panetti's case also brought together various national conservatives, who wrote a letter to Republican Texas governor Rick Perry, reports the Houston Chronicle.

Panetti was convicted in 1995 to death for the murders of Joe and Amanda Alvarado. During his trial he defended himself, wearing a cowboy outfit. He called to the witness stand the pope, the late John F. Kennedy and Jesus.