Image copyright Nevada Department of Corrections Image caption Nevada's last execution was in 2006

A Nevada execution, which would have been the first in the US to use the synthetic opioid fentanyl, has been delayed by a judge.

Pharmaceutical firm Alvogen argued the state had illegitimately obtained one of its drugs and that the proposed drug combination was untested in executions.

Scott Raymond Dozier, a twice-convicted killer, has said he prefers to be executed rather than stay in prison.

On Wednesday morning, a judge sided with the company and ordered a delay.

Clark County District Court Judge Elizabeth Gonzalez issued the ruling after Alvogen argued that the prison had tricked their distributor into selling the drug, despite the company's known objection to selling it for executions.

The execution of 47-year-old Dozier had been scheduled for Wednesday night.

Officials had planned to use an untried three-drug lethal injection made up of the sedative midazolam, the synthetic opioid fentanyl and the muscle paralytic cisatracurium.

The drug cocktail is meant to slow breathing and eventually paralyse the prisoner's muscles to stop their breathing.

Fentanyl, the synthetic opioid at the heart of the US opioid epidemic, has never been used in an execution before, but it is midazolam at the centre of Alvogen's last-minute lawsuit.

The New Jersey-based drug company Alvogen said it does not want its drugs used in "botched" executions, according to court documents.

Midazolam has been used as a replacement for Valium - diazepam - after Nevada's stocks of the sedative expired, a Nevada Department of Corrections (NDOC) release said.

Last year, the state refused to return its stock of fentanyl and diazepam to drug company Pfizer.

Alvogen also claims the prison obtained its midazolam illegally, "despite a clear and unambiguous prior warning" from the company that they could not acquire it from company or a third party.

A spokeswoman for Nevada Department of Corrections, Brooke Santina, told the Reno Gazette Journal before the court hearing on Wednesday that the agency would not comment on the pending litigation.

Image copyright Science Photo Library Image caption Fentanyl, the synthetic opioid at the heart of the US opioid epidemic, has never been used in an execution before

The lawsuit also alleges that prison officials acknowledged attempts to conceal the fact that they had obtained the midazolam.

Alvogen notes that midazolam was used in several "botched" executions, including that of Clayton Lockett in 2014, where Lockett regained consciousness during his execution and died 40 minutes later of a heart attack.

But Dozier, who has been on death row at Ely State Prison since 2007, has said he wishes to die.

"I've been very clear about my desire to be executed ... even if suffering is inevitable," he wrote in a note to a judge who had delayed his execution in November, according to the Associated Press.

He has repeated his statement in interviews with local media.

Dozier received the death sentence for robbing, killing and dismembering 22-year-old Jeremiah Miller in 2002. Miller's head was never found and he was identified by tattoos on his torso.

In 2005, police found the grave of another victim, 26-year-old Jasen Greene, who Dozier had shot and killed.

Media playback is unsupported on your device Media caption Are we missing the real opioid drug crisis?

Pharmaceutical companies have ethically opposed states using their drugs for capital punishment for years, but this is only the second lawsuit to be filed, the AP reported.

Wednesday's ruling marks the first time a drug maker successfully sued to block an execution.

Last year, a pharmaceutical company sued the state of Arkansas over drugs used in its lethal injections, but was unsuccessful.

Maya Foa of the anti-death penalty group Reprieve cheered the judge's ruling, saying that "the makers of medicines have a right to decide how their products are used".

" Healthcare companies make drugs to save lives, not to end them in experimental executions."