He refused to take a plea bargain. At his first trial, Mr. O’Hara was convicted, but the verdict was overturned on appeal. The second time, the jury could not reach a verdict.

At his third trial, prosecutors called to the witness stand a woman who owned the house before Mr. O’Hara used it as an address. Was there an apartment in the basement? No, she said, there was not.

Guilty! Convicted of an E felony, Mr. O’Hara was automatically disbarred, had to pay $15,192 in fines and restitution, and was sentenced to community service of 1,500 hours — nine months — picking up garbage in Brooklyn parks.

A judicial committee gave him back his law license, deciding that the prosecution looked fishy. Over the years, lawyers unearthed documents in the Brooklyn district attorney’s office that showed illegal tactics had been used in cases far more serious than Mr. O’Hara’s. In time, this helped lead to the ouster of Mr. Hynes by Kenneth P. Thompson, who ran on a platform of undoing what he saw as the injustices of the Hynes administration. Mr. Thompson, who died in October, set up a special unit to look into possible wrongful convictions.

One of the lawyers who had uncovered wrongdoing in the district attorney’s office, Joel B. Rudin, took up Mr. O’Hara’s cause, filing 620 pages of arguments and exhibits with the court. Mr. Thompson agreed to review it.

Investigators traveled to the southwest United States to interview the former owner of the house. She told them that she and her husband had indeed finished the basement as a recreation area. Asked in court if it were an apartment, she had said no. But no one asked if someone could live there.

That was the entire crux of the case: Mr. O’Hara could actually have lived there. Mark Hale of the district attorney’s office said these facts created “insurmountable reasonable doubt as to his guilt.”