Image copyright Getty Images Image caption A shortage of drugs led to some states implementing alternatives to the lethal injection

The US Supreme Court has upheld the use of a contentious drug used in executions, saying it does not violate a ban on cruel and unusual punishment.

The ruling is a setback to opponents of the death penalty, who say midazolam is not suitable for lethal injections.

The drug raised concerns after it was used in executions in three US states in 2014 that took longer than usual.

Executions have been delayed recently in the US amid problems buying drugs as many firms have refused to sell them.

In the case, called Glossip v Gross, three inmates in Oklahoma argued that the sedative could not achieve the level of unconsciousness required for surgery, meaning severe pain and suffering was likely.

This, they said, was contrary to the Eighth Amendment of the US Constitution, which forbids "cruel and unusual punishments".

But the court, in a 5-4 decision, handed a loss to the inmates after judges ruled they did not prove that midazolam was cruel and unusual when compared to known and available alternatives.

More on the death penalty:

Delivering the opinion of the court, Justice Alito said the inmates had "failed to identify a known and available alternative method of execution that entails a lesser risk of pain".

In dissent, Justice Sonia Sotomayor said the ruling left inmates "exposed to what may well be the chemical equivalent of being burned at the stake".

Justice Stephen Breyer, who also voted against the ruling, said the time had come for the court to debate whether the death penalty itself is constitutional.

But Justice Alito responded by saying the dissenting judges had resorted to "outlandish rhetoric" that revealed the weakness of their legal arguments.

Image copyright AP Image caption US states have found it increasingly difficult to get drugs needed for lethal injections

Several US states turned to midazolam when European manufacturers stopped supplying sodium thiopental to US prisons because of an EU ban on the sale of products used in lethal injections.

The shortage of various drugs used by the 32 US states that still have capital punishment led to some reintroducing other controversial methods, such as the gas chamber and firing squad.

The BBC's Gary O'Donoghue in Washington says Monday's ruling should make it easier for states to continue using a lethal drug cocktail to carry out death sentences.