A man imprisoned for more than two decades for the 1990 murder of a Brooklyn rabbi was released Thursday after a judge vacated his conviction.

David Ranta was freed after a review by the Brooklyn district attorney’s office at the behest of his attorney, Michael Baum, concluded that detectives had mishandled the case.

“[The review] concluded that the foundation upon which Mr. Ranta’s conviction was based had been eroded,” District Attorney Charles Hynes said in a statement. “No remaining evidence could lead to Mr. Ranta’s conviction, were he to be retried.”

Baum brought the case to the district attorney’s office after a Conviction Integrity Unit was established in April 2011.

Prosecutors asked state Supreme Court Justice Miriam Cyrulnik to vacate the conviction “in the interest of justice.”

Ranta was accused of shooting Rabbi Chaskel Werzberger on Feb. 8, 1990, during a botched robbery of a diamond courier in Williamsburg. Werzberger was sitting in a nearby car when a gunman shot him through the driver’s side window, pulled him out and drove off. Ranta was convicted in May 1991.

One witness had come forward and claimed that a detective instructed him to pick Ranta from a lineup, according to court documents. Another said in an affidavit that she lied about everything she told detectives and the district attorney’s office at the time.

“Had the new evidence been available at the time of the trial, it would have created a probability that the verdict would have been more favorable to the defendant,” wrote Assistant District Attorney John O’Mara, who led the review of Ranta’s case, in a court document.

A judge approved prosecutors’ request to have Ranta released from a prison outside Buffalo, N.Y.

“Sir, you are free to go,” Cyrulnik said to Ranta, who was in the court with relatives.

Another Riverhead swastika … Teacher sentencing … GivingTuesday Credit: Newsday

Suffolk 911 outage ... MS-13 associate sentenced ... Cease fire extended ... A.I. robot for kids 

Another Riverhead swastika … Teacher sentencing … GivingTuesday Credit: Newsday

Suffolk 911 outage ... MS-13 associate sentenced ... Cease fire extended ... A.I. robot for kids 

Latest video

Newsday LogoYour Island. Your Community. Your News.Digital AccessOnly 25¢for 5 months
ACT NOWSALE ENDS SOON | CANCEL ANYTIME