The first cases, he wrote, concerned the equal treatment of prisoners of different faiths.

In 2019, for instance, the court allowed by a 5-to-4 vote the execution of an Alabama inmate, Domineque Ray, a Muslim whose request that his imam be present had been denied. At the time, Alabama allowed only a Christian chaplain employed by the prison system to offer spiritual guidance to condemned inmates during their last moments.

Justice Elena Kagan, writing for the dissenters in 2019, said the majority was “profoundly wrong.” Under Alabama’s policy, she wrote, “a Christian prisoner may have a minister of his own faith accompany him into the execution chamber to say his last rites.”

“But if an inmate practices a different religion — whether Islam, Judaism or any other — he may not die with a minister of his own faith by his side,” Justice Kagan wrote.

A few weeks later, the court confronted a similar case from Texas and came to a different conclusion, staying the execution of a Buddhist inmate whose request that his spiritual adviser be present in the execution chamber had been denied.

In a brief, unsigned order, the court said that Texas could not execute the inmate, Patrick H. Murphy, “unless the state permits Murphy’s Buddhist spiritual adviser or another Buddhist reverend of the state’s choosing to accompany Murphy in the execution chamber during the execution.”

Those decisions could be reconciled, Justice Kavanaugh wrote, because only Mr. Murphy had raised his claim in a timely manner.

They established, Justice Kavanaugh wrote, “the bedrock religious equality principle” that “states could not allow religious advisers of some religions while excluding religious advisers of other religions.” But states remained free to bar all spiritual advisers from death chambers.