An Arizona woman who spent more than two decades on death row in her 4-year-old son's killing was exonerated Monday, bringing an end to a controversial case that relied almost entirely on the work of a detective with a long history of misconduct.

Debra Milke hugged her supporters and sobbed as she left the courtroom, where a judge formally dismissed the case less than a week after prosecutors lost their final appeal. In a brief hearing, Judge Rosa Mroz also allowed Milke, who has been free on bond since 2013, to have her electronic-monitoring ankle bracelet removed.

Milke was convicted of murder in 1990 in the death of her son, Christopher. Authorities say Milke dressed him in his favorite 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 didn't want the child anymore and didn't want him to live with his father. Milke has maintained her innocence and denied that she confessed to the killing. The two men who led her child to his death were convicted of murder but refused to testify against Milke.

An appeals court overturned Milke's conviction in 2013, ruling that prosecutors failed to disclose a detective's history of misconduct. Her conviction was based entirely on a confession Milke gave to the now-discredited detective, Armando Saldate.

Multiple court rulings in other cases said the now-retired officer either lied under oath or violated suspects' rights during interrogations.

In a scathing 2013 opinion, a federal appeals court leveled harsh criticism over the case.

"No civilized system of justice should have to depend on such flimsy evidence," the 9th U.S. Circuit Court of Appeals said.

Saldate has said he would not testify at any retrial, citing fears of potential federal charges based on the 9th Circuit's accusations of misconduct. Both county and federal authorities have said they don't intend to seek charges against the detective based on any accusations leveled by the federal appeals court.

Milke filed a lawsuit earlier this month against the city of Phoenix, Maricopa County and numerous individuals. She alleges authorities violated her civil rights. She also contends she was denied a fair trial and was a victim of malicious prosecution.