Get breaking news alerts and special reports. The news and stories that matter, delivered weekday mornings.

WASHINGTON — The Supreme Court is ordering a new state court hearing to determine whether an Alabama death row inmate is so affected by dementia that he can't be executed.

The justices ruled 5-3 on Wednesday in favor of inmate Vernon Madison, who killed a police officer in 1985. His lawyers say he has suffered strokes that have left him with severe dementia.

Vernon Madison is one of Alabama's longest-serving death row inmates. Alabama Department of Corrections via Reuters

Chief Justice John Roberts joined the court's four liberals in siding with Madison.

The high court ruling is not the end of the case. Justice Elena Kagan says in her majority opinion that, if the state wants to put Madison to death, an Alabama state court must determine that Madison understands why he is being executed.

The justices have previously said the constitutional ban on cruel and unusual punishment means that people who are insane, delusional or psychotic cannot be executed.

But Kagan, reading a summary of her ruling, said, "Based on our review of the record, we can't be sure that the state court recognized that Madison's dementia might render him incompetent to be executed."

Justices Samuel Alito, Neil Gorsuch and Clarence Thomas, who last year would have allowed the execution to proceed without hearing the case, dissented. Justice Brett Kavanaugh was not yet on the court when arguments took place in early October.