In an opinion that harshly criticizes the tactics of the police and prosecutors, an Illinois appellate court on Friday night reversed the conviction of Juan Rivera, who has spent 19 years in jail for the 1992 rape and murder of an 11-year-old baby sitter in a suburb of Chicago.

Mr. Rivera, who is 39 and serving a life sentence, has been convicted three times for killing the sitter, Holly Staker, based on the strength of a confession that was obtained after four days of questioning. There was no physical evidence linking him to the crime, which occurred in Waukegan, Ill., and DNA testing in 2005 excluded him as the source of sperm found in Holly’s body.

In the most recent trial, in 2009, prosecutors explained the DNA evidence by positing two theories: that the sperm sample had been contaminated and that Holly had been sexually active. Mr. Rivera’s case was the subject of a Nov. 27 article in The New York Times Magazine that examined efforts by prosecutors, particularly in Lake County, Ill., where Waukegan is located, to discredit DNA evidence that supported the innocence claims of men they had prosecuted.

Mr. Rivera, speaking by telephone from prison, said that he learned of the ruling early Saturday from several inmates, and that the news was greeted by cheers in his cellblock. “It was overwhelming,” he said. “It’s still a shocker at this point.