A judge signed an order Thursday freeing a man from prison where he had spent more than two decades after being wrongfully convicted of the brutal rape of a 25-year-old woman.

Judge John Byrne signed the order in Bronx Criminal Court while Alan Newton stood quietly with his attorney. His family whooped loudly in the crowded courtroom when he first appeared, dressed in a beige suit with a bright blue shirt.

After his courtroom appearance, Newton had to await the completion of paperwork that would allow him to walk out of the courthouse as a free man.

The nonprofit Innocence Project and prosecutors from the Bronx district attorney's office had asked for Newton's 1985 conviction to be vacated based on recent testing on a rape kit used for the woman after the incident.

Newton, now 44, was convicted of raping the woman in an abandoned Bronx building in June 1984. He was sentenced in 1985 to up to 40 years in prison.

In 1994 he filed a motion asking that new DNA testing be conducted, but the request was denied because the evidence was unavailable, the Innocence Project and prosecutors wrote in papers filed to the court.

A similar request was granted four years later, but testing of the victim's clothing "failed to yield the presence of male DNA," the papers said.

At the request of the Innocence Project, the district attorney's office last year asked the New York Police Department's property clerk division to search for the rape kit at an evidence warehouse in Queens.

Despite what Innocence Project lawyers and prosecutors said were earlier claims that it was lost or had been destroyed, officials found the kit, which was tested for DNA by two labs earlier this year.

The result "conclusively excludes" Newton as the assailant, according to the papers.

Byrne praised the district attorney's office for its help in pursuing evidence that led to Newton's release.