U.S. District Judge Denny Chin threw out Jose Morales' conviction and released him without bail.
Prosecutors said they would fight to reinstate the conviction.
Morales, 31, was found guilty in 1988 of beating and stabbing to death Jose Antonio Rivera in the South Bronx.
At a hearing last week, the Rev. Joseph Towle testified that another neighborhood gang member, Jesus Fornes, had told him in 1989 that he and two other people - but not Morales - were involved in the slaying.
On Tuesday, the judge declared that if the priest's statement had been disclosed at trial, ``it is difficult to imagine that any reasonable jury could find Morales guilty beyond a reasonable doubt.''
The priest testified that he kept quiet over the years because he considered the confession confidential. But he said he later came to the conclusion that it was not a sacramental confession as defined by Roman Catholic law, even though he had given Fornes absolution.
According to the priest, Morales' co-defendant, Ruben Montalvo--also jailed for the past 12 years--was falsely accused as well. The judge indicated he would also release Montalvo once his lawyers bring that appeal before him.
The case had posed the question of what constitutes a confession in the Catholic Church.
Prosecutors opposed the request for a new trial, saying Fornes' words were a valid confession and thus inadmissible in court under a state law establishing the ``clergy-penitent privilege.'' Under the law, the privilege can be waived if the confessor agrees. However, Fornes is now dead.
Wanda Rivera, the daughter of the murder victim, left court in tears, saying Morales and Montalvo brutally killed her father.
``Just because of a priest, they want to release them,'' she said. ``The system has failed.''