U.S. District Judge Anita Brody found that James Dennis' conviction was based on dubious eyewitness testimony, bad police work and a poor defense by his lawyer, The Philadelphia Inquirer reported. She said he must be freed if he is not retried within six months.
"The Commonwealth of Pennsylvania has committed a grave miscarriage of justice," Brody said.
Chedell Ray Williams, 17, a student at Olney High School, was killed in October 1991 by two men who demanded her $450 earrings. Dennis was the only person ever charged with the crime.
The weapon used in the shooting and the earrings were never recovered and police found no forensic evidence against Dennis. His conviction was based on testimony from three eyewitnesses, although other witnesses had said the shooter was taller and weighed more.
Brody in her 40-page opinion said police never told the defense about evidence that might have led in other directions. As one example, a girl who was with Williams told relatives she recognized the killers from school and knew their nicknames.
District Attorney Seth Williams said his office is considering whether to appeal the decision. He said Brody's findings were based on "slanted factual allegations."
Dennis, now 42, is on death row at the state prison in Waynesburg. His sister, Hope Dennis, told the Inquirer no one in his family has seen him for five years because he gets too upset by face-to-face visits.
Pennsylvania has only executed three men since it reinstated the death penalty, all volunteers who gave up their appeals. But the state has one of the largest death rows in the country with more than 200 people under sentence.
2014: The Year in Music [PHOTOS]