A divided Supreme Court on Monday turned aside claims by death-row inmates that a drug to be used in their executions would lead to an unconstitutional level of suffering, a narrow but unequivocal ruling that made clear that states have leeway in carrying out the death penalty.

The justices ruled 5 to 4 against inmates in Oklahoma, who alleged that the use of a sedative called midazolam has resulted in troubling executions that violate the Constitution’s prohibition on cruel and unusual punishment. Executions in Oklahoma and elsewhere have generated national headlines about inmates writhing in pain or taking hours to die when the drug was involved.

Supreme Court opinion on lethal injection drug

The relatively limited issue in Glossip v. Gross gave way to a broader dispute among the court's nine members, one that reflects the debate in society: Can the ultimate punishment for the most horrendous acts be equitably and humanely applied and confined to the truly guilty?

Two justices who have been on the Supreme Court bench for decades wrote a long dissent saying it was time for the court to take another look at whether the death penalty could ever be carried out in accordance with the Constitution.

“I believe it highly likely that the death penalty violates the Eighth Amendment,” Justice Stephen G. Breyer wrote, joined by Justice Ruth Bader Ginsburg. “At the very least, the court should call for full briefing on the basic question.”

Two other justices with even longer tenures dismissed Breyer’s 41 pages of argument and five pages of charts and maps as “gobbledy-gook.” Justice Antonin Scalia, joined by Justice Clarence Thomas, said the Constitution leaves to the people the decision of whether there should be capital punishment.

“By arrogating to himself the power to overturn that decision, Justice Breyer does not just reject the death penalty, he rejects the Enlightenment,” Scalia wrote.

The lethal-injection decision and two others were the final rulings in cases the court considered this term. As is often the case at the end, there were signs of raw nerves. Thomas and Scalia, in dissents and comments from the bench in unrelated cases, both spoke ruefully of last week’s landmark decision recognizing a constitutional right for gay couples to marry.

In the death penalty case, four justices summarized their views from the bench, a sign of the importance it carried for them and the vehemence of their disagreement.

In rejecting the challenge to midazolam, the majority opinion was somewhat dry and straightforward.

Justice Samuel A. Alito Jr. wrote for the majority that the death row inmates’ challenge failed because they did not meet their burden of identifying a “known and available alternative method of execution” that would carry a lesser risk of pain. He said that was required under the court’s previous ruling upholding lethal injection.

Additionally, he said that the plaintiffs had not proven that a massive dose of midazolam “entails a substantial risk of severe pain.”

Alito was joined in the opinion by Chief Justice John G. Roberts Jr. and Justice Anthony M. Kennedy, as well as Scalia and

Justice Sonia Sotomayor wrote a scathing dissent. She said the court’s determination that midazolam does not cause an intolerable risk of severe pain “is factually wrong.” She said the court’s conclusion that the prisoners must identify an “available alternative means by which the state may kill them is legally indefensible.”

“Petitioners contend that Oklahoma’s current protocol is a barbarous method of punishment — the chemical equivalent of being burned alive,” she wrote. “But under the court’s new rule, it would not matter whether the state intended to use midazolam, or instead to have petitioners drawn and quartered, slowly tortured to death, or actually burned at the stake.”

Alito’s response to that was the most emotional part of his opinion. The dissent’s “resort to this outlandish rhetoric reveals the weakness of its legal arguments,” he concluded.

Dale Baich, one of the attorneys for the death-row prisoners, said in a statement: “Because the court declined to require that states follow scientific guidelines in determining their lethal injection procedures, states will be allowed to conduct additional human experimentation when they carry out executions by lethal injection.”

Douglas Berman, a law professor at Ohio State University and an expert on criminal sentencing, said the decision was a “big win” for states trying to carry out executions. (A dwindling number of states carry out the death penalty.)

And he found it significant that only two justices called for another look at the constitutionality of the death penalty. “Seven current justices apparently do not question the death penalty’s essential constitutionality, including the five youngest justices,” Berman said in a statement. That “suggests to me that abolitionists still have a lot more work to do.”

Breyer made the case for starting that conversation with his lengthy dissent.

He noted that for nine years, the court did not allow executions. “In 1976, the court thought that the constitutional infirmities in the death penalty could be healed,” Breyer wrote, adding, “Almost 40 years of studies, surveys and experience strongly indicate, however, that this effort has failed.”

He said there were three fundamental defects: “serious unreliability, arbitrariness in application and unconscionably long delays that undermine the death penalty’s penological purpose.”

As a result, he said, 30 states have either abolished the death penalty or have not carried out an execution in eight years. Only about a third of the country’s residents live in states where executions occur at least occasionally.

Scalia said the ills that Breyer described are the results of “abolitionists” who contest every death sentence beyond reason. He said Breyer’s “invocation of the resultant delay as grounds for abolishing the death penalty calls to mind the man sentenced to death for killing his parents, who pleads for mercy on the ground that he is an orphan.”

How efforts to legalize same-sex marriage culminated in Supreme Court decision

The justices were revisiting the issue of lethal injection for the first time since 2008, when they upheld a three-drug combination and said it did not violate the Constitution’s ban on cruel and unusual punishment. At the time, these drugs were used across the country.

But an ongoing shortage of lethal injection drugs, arising largely from European objections to capital punishment, has stopped the production of those drugs and caused states to find new ones, create different protocols and seek other methods.

When Oklahoma officials could no longer obtain the drug they used, they turned to midazolam. It was used in three problematic executions last year, turning the drug into a focal point for debates about lethal injections.

The most high-profile of these was Oklahoma’s bungled attempt to execute convicted murderer Clayton Lockett. He kicked, grimaced and survived for 43 minutes after the execution began. He eventually died after officials had already halted the process, and a state investigation blamed the error on the manner in which the execution team inserted the needle.

Most Americans support the death penalty, but that number is falling

Oklahoma Gov. Mary Fallin (R) released a statement Monday saying the ruling “upholds the letter and the spirit of the law as it is written.” Authorities in that state vowed to resume executions, which have been on hold since the court agreed to hear this case in January.

The three surviving inmates named in the case were convicted of murder and sentenced to death, while the fourth was executed in January, shortly before the justices took the case.

In its court filings, Oklahoma laid out the crimes for which each man was convicted: Richard Glossip hired someone to kill his employer; John Grant stabbed a prison food service supervisor while in jail; and Benjamin Cole snapped his 9-month-old daughter’s spine.

In addition to Oklahoma, the attorneys general in Florida and Alabama said that they also believed their paths were cleared to resume executions.

Experts said Monday that they had not heard so far of states scrambling to adopt midazolam, which even before the questionable executions was not used widely by states.

“This is a narrow decision involving one drug in one state,” said Deborah W. Denno, a law professor at Fordham University in New York, who has been critical of the lethal injection process. The ruling involves “a drug that’s used in a handful of states, and hasn’t been used all that much,” she said. “Is it going to increase? It’s unclear.”

Midazolam was also used last year in the execution of an Arizona inmate who gasped and snorted and took nearly two hours to die, as well as the lethal injection of an Ohio inmate who gasped and choked for nearly half an hour before dying.

Sandhya Somashekhar and Mark Berman contributed to this report.