The U.S. Supreme Court has granted an Alabama inmate a stay of execution, CNN reports.

The ruling was made after lawyers representing Vernon Madison, 67, argued that his dementia prevents him from remembering the murder he was convicted of years ago.

The state of Alabama had planned to execute Madison on Thursday evening, but less than 30 minutes before the scheduled death, Justice Clarence Thomas issued a temporary stay.

Roughly two and a half hours later, the court announced that a stay had been granted. The stay is in effect while the court decides how to rule on an appeal from the defense.

Madison was convicted three times in the shooting of Mobile, Alabama police Cpl. Julius Schulte. In 1985, Schulte was responding to a domestic disturbance call. Madison, on parole at the time, was convicted of sneaking up behind Schulte and shooting him twice in the head. He also shot his girlfriend, but she survived.

During his first two trials, Madison argued that his mental illness drove him to act and that he wasn’t guilty as a result. At his third trial, he argued self-defense.

Madison’s attorneys, from the Equal Justice Initiative, filed a petition on his behalf with the Supreme Court on Wednesday.

“Given Alabama’s rejection of judicial override, the death sentence in this case constitutes cruel and unusual punishment and violates Mr. Madison’s rights to a jury, fair and reliable sentencing and to due process and equal protection of the laws as guaranteed by the Fifth, Sixth, Eighth and Fourteenth Amendments of the United States Constitution and Alabama law,” his attorneys wrote in their petition. “Mr. Madison suffers from vascular dementia as a result of multiple serious strokes in the last several years, and no longer has a memory of the commission of the crime for which he is to be executed. He does not understand why the state of Alabama is attempting to execute him,” they continued.

Currently, 182 inmates are serving sentences on Alabama’s death row, three of who have been there longer than Madison.