When investigators approached two other witnesses in the case, they immediately admitted that they had lied.

The two career criminals who implicated Mr. Ranta in the crime used their cooperation in the case as a means to obtain get-out-of-jail excursions provided by Mr. Scarcella, who before retiring had been well regarded for his ability to solve homicides at a time when Brooklyn was awash in violence. He has repeatedly denied any wrongdoing.

Mr. Ranta had always accused the detective of manufacturing his confession. Mr. Scarcella said Mr. Ranta confessed while handcuffed to a bench at Central Booking. Although the allegation about the confession was never proven, the mounting questions about Mr. Scarcella’s methods made it increasingly suspect.

Prosecutors also discovered that Mr. Scarcella had followed up on an anonymous telephone call that attributed the killing to a robber named Joseph Astin. Mr. Scarcella questioned Mr. Astin’s wife and tried to track down a parole officer to collect recent photographs of him. But he dropped that lead when Mr. Astin died in a car accident, and then the officer never submitted any paperwork documenting the time spent investigating him.

Years later, Mr. Astin’s widow came forward to say her husband was the real killer, but legal efforts to free Mr. Ranta based on that information failed.

Two months after Mr. Ranta was released, he filed a notice that he would sue the city. Negotiations took place for several months under the previous comptroller, John C. Liu. But it was Mr. Liu’s successor, Scott M. Stringer, swayed by the fact that the Brooklyn district attorney’s office had joined in the motion to free Mr. Ranta from prison, who ultimately agreed to settle the case.

Image Mr. Scarcella, a detective who has been accused of inventing confessions, coercing witnesses and recycling informers. Credit... Suzanne DeChillo/The New York Times

“This settlement is in the best interests of all parties and closes the door on a truly regrettable episode in our city’s history,” Mr. Stringer said in a statement. “I am pleased that my office was able to move quickly on this case.”