A state appeals court has ordered the dismissal of murder charges against a woman who spent 22 years on Arizona’s death row for the killing of her four-year-old son.

The Arizona court of appeals on Thursday levelled harsh criticism against prosecutors over their failure to turn over evidence during Debra Jean Milke’s trial about a detective with a long history of misconduct and lying. The court called prosecutors’ actions “a severe stain on the Arizona justice system”.

A three-judge panel of the appeals court said it agreed with Milke’s argument that a retrial would amount to double jeopardy.

The failure to disclose the evidence “calls into question the integrity of the system and was highly prejudicial to Milke”, the court wrote. “In these circumstances – which will hopefully remain unique in the history of Arizona law – the most potent constitutional remedy is required.”

The court said the charges against Milke in connection with the 1989 death of her son Christopher cannot be refiled, but prosecutors could appeal against Thursday’s ruling to the state supreme court.

Authorities say Milke dressed her son in his favourite outfit and told him he was going to see Santa Claus at a mall in December 1989. He was then taken into the desert near Phoenix by two men and shot in the back of the head. Authorities say Milke’s motive was that she did not want the child any more and did not want him to live with his father.

She was convicted in 1990 and sentenced to death. The case rested largely on her purported confession to Phoenix police detective Armando Saldate, which he did not record.

Milke, 50, was on death row for two decades, and the Arizona supreme court had gone so far as to issue a death warrant for Milke in 1997. The execution was delayed because she had yet to exhaust federal appeals.

The appeals court said on Thursday it was not expressing an opinion on Milke’s guilt or innocence, though it heavily criticised authorities for staking much of their case on a detective with credibility problems.

A federal appeals court threw out Milke’s first-degree murder conviction in March 2013, saying prosecutors knew about a history of misconduct by the detective but failed to disclose it. Maricopa County prosecutors were preparing for a retrial.

Lori Voepel, Milke’s appellate attorney, was ecstatic at Thursday’s victory.

Milke has been free on bail since September 2013 as she awaited retrial.

“This is really a sock in the gut – it’s a cheap shot,” said Arizona Milke, Christopher’s father and Debra Milke’s ex-husband. “She shouldn’t walk free, because she’s guilty.”

Maricopa County attorney Bill Montgomery, whose office is handling the case, said he plans to ask the Arizona supreme court to overturn Thursday’s ruling.

Montgomery said the accusations of misconduct happened well before he took over as the county’s top prosecutor and would not happen today, citing safeguards such as having detectives record interviews with suspects.

Montgomery also said he would not be pursuing the case if he believed the evidence could not lead to a conviction in Christopher’s killing.

“He should not be forgotten in all of this. Justice and due process for Christopher is a right that he has, too,” Montgomery said. “And it’s the job of prosecutors, unfortunately in situations like this, where we have to be the voice of the voiceless.”

Milke has maintained her innocence and denied she ever confessed to the killing. The two men who led her child to his death in the desert were convicted of murder but refused to testify against Milke.

That left jurors with Saldate’s word alone that she told him about her involvement. Saldate has since retired, and the Associated Press has made repeated efforts to reach him for comment.

In its ruling overturning Milke’s conviction, the ninth US circuit court of appeals cited numerous instances in which Saldate committed misconduct in previous cases, including lying under oath and violating suspects’ rights. The federal appeals court also asked the Justice Department to investigate whether Saldate had committed civil rights violations.

Prosecutors insist Milke is guilty, but their ability to try her again was limited by the fact that Saldate said he would not testify. He fears potential federal charges based on the ninth circuit’s accusations of misconduct.

In December, superior court judge Rosa Mroz granted Saldate’s request to assert his fifth amendment right, allowing him to refuse to take the stand.

The state court of appeals overturned that ruling in April and said Saldate would be forced to testify at the retrial. Both county and federal authorities said they do not intend to seek charges against the detective based on any of the accusations levelled by the federal appeals court.

Milke, whose mother was a German who married a US air force military policeman in Berlin in the 1960s, has drawn strong support from citizens of that nation and Switzerland, neither of which has the death penalty.

Milke’s mother died in Germany this year after a battle with cancer. A week before the death in August, a judge had denied Milke’s request for permission to travel to Germany to visit her mother.