MONTGOMERY, Ala. — The U.S. Supreme Court on Thursday halted the execution of Alabama inmate Vernon Madison after attorneys argued that dementia had left the 67-year-old unable to remember killing a police officer three decades ago.

Justices issued the stay on the same evening that Madison was scheduled to receive a lethal injection at a southwest Alabama prison. The court delayed the execution to consider whether to further review the case and claims that Madison is mentally incompetent.

Madison was sentenced to death for the 1985 killing of Mobile police Officer Julius Schulte. Schulte had responded to a call about a missing child made by Madison’s then-girlfriend. Prosecutors have said that Madison crept up and shot Schulte in the back of the head as he sat in his police car.

Madison’s attorneys argued that strokes and dementia had left Madison unable to remember killing Schulte or fully understand his looming execution. The Supreme Court has previously ruled that condemned inmates must have a “rational understanding” that they are about to be executed and why.

“We are thrilled that the court stopped this execution tonight. Killing a fragile man suffering from dementia is unnecessary and cruel,” attorney Bryan Stevenson, of the Equal Justice Initiative, said Thursday after the stay was granted.

The Alabama attorney general’s office opposed the stay, arguing a state court has ruled Madison competent and that Madison has presented nothing that would reverse that finding.

Appeals courts have been divided over Madison’s case.

In 2016, the 11th U.S. Circuit Court of Appeals halted Madison’s execution seven hours before he was scheduled for a lethal injection. The U.S. Supreme Court later opened the way for the execution to proceed.

The court, in an unsigned 2017 opinion, said testimony showed Madison “recognizes that he will be put to death as punishment for the murder he was found to have committed,” even if he doesn’t remember the killing itself.

Justices noted then that federal courts’ review of Madison’s case is constrained because of a 1996 law intended to limit federal judges’ second-guessing of state court decisions. State courts upheld Madison’s death sentence, and the Supreme Court, applying the 1996 law, said those decisions should be respected. The justices have never ruled on whether someone who doesn’t remember their crime can be executed

Madison’s attorneys also have asked for a stay on the grounds that a judge sentenced him to death, even though a jury recommended life imprisonment. Alabama lawmakers in 2017 changed the law to no longer allow a judge to override a jury’s sentence recommendation in death penalty-eligible cases.

The Alabama attorney general’s office, in opposing the stay, said the 2017 legislation was not retroactive and did not affect Madison and other inmates already on death row.

Justices Clarence Thomas, Samuel Alito and Neil Gorsuch were opposed to the stay, according to the order issued Thursday evening.