New York City agreed on Thursday to pay $9.9 million, the largest personal settlement in its history, to a man who served almost two decades in prison but was released after evidence surfaced that he had been framed for murder by a corrupt detective.

The man, Barry Gibbs, had served 19 years in prison when his conviction was overturned in 2005 after questions were raised about how his case had been handled by Louis J. Eppolito, a New York City police detective, one of the notorious “Mafia cops” serving life in prison for taking part in mob-related killings.

Mr. Gibbs sued the city in 2006, and a civil trial was scheduled to begin this month in United States District Court in Brooklyn.

“The settlement I’m happy with; it was my bottom-line settlement,” Mr. Gibbs said in an interview, sounding almost indifferent to the news. “They are permanent scars,” he added. “It’s been a long road. I’ve been through a lot, and it was very traumatic for me.”