More than 35 years after Kevin O’Loughlin was convicted of raping an 11-year-old girl in Framingham, a jury on Tuesday found the gourmet food salesman did not commit the crime and awarded him $5 million in damages.

The 14-member jury determined that O’Loughlin was innocent by “clear and convincing” evidence after an emotional week-long trial in Suffolk Superior Court that pitted the divorced father of two against a rape victim, now in her 40s, who still maintains she identified the right man.

O’Loughlin had sought compensation under a 2004 law that allows plaintiffs to seek damages from the state if they can prove they are innocent. He filed suit three years ago after a Superior Court judge vacated his 1983 conviction and prosecutors decided not to retry him, citing evidence of another possible suspect that cast, “real doubt on the justice of the conviction.”

O’Loughlin said he could barely believe the jury ruled in his favor.

“I really didn’t feel it was going my way at all because nothing really has,’’ he said. “I've always said I've been innocent and I finally got that proven in court.’’

During the trial, O’Loughlin described being beaten and threatened during a four-year stint in state prison, considered a “child molester” by inmates and guards, and a lifetime trying to escape the shame of his conviction.

Despite the $5 million verdict, O’Loughlin will be getting far less. In April, Governor Charlie Baker increased the maximum compensation a plaintiff can win from $500,000 to $1 million and added attorneys fees, but it is unclear whether the changes are retroactive.

O’Loughlin is only the second person since the erroneous-conviction law was passed to win a judgment after a jury trial, state records show.

The amendments to the 2004 law were added after defense attorneys and former inmates complained it set an unreasonably high bar to get compensation, forcing many plaintiffs to settle rather than fight a timely and costly legal battle. As of last fall, 67 people had filed for compensation and less than half had received any money, according to state data.

The Office of the Attorney General, which represented the state in this case, also has argued that O’Loughlin’s suit was “moot” because he recently received a $900,000 settlement from the Town of Framingham for its role in his conviction, court records show.

O’Loughlin’s attorney Michael Kendall criticized the Attorney General’s office for aggressively fighting O’Loughlin’s case, despite findings from prosecutors that they may have gotten the wrong man. “The attorney general’s office has been so hostile to these cases that it was important to get a verdict and important to get a judgment from a jury,’’ he said.

Emily Snyder, a spokeswoman for Attorney General Maura Healey, said in a statement that wrongful conviction cases are among the most difficult matters the office handles. “For 35 years, the survivor has never wavered in her identification of Mr. O’Loughlin, and she showed great courage in testifying,” Snyder said. “We respect the jury’s decision.”

O’Loughlin’s case was first detailed in a 2016 story by the New England Center for Investigative Reporting in the Boston Globe. His conviction was vacated after a Framingham detective, now retired, found evidence several years ago that another man with a history of sexual offences who looked like O’Loughlin may have committed the crime.

The detective, Kevin Slattery, took his findings to the Middlesex District Attorney’s office, which re-opened the case. They had found evidence pointing to another suspect they described as bearing “a striking facial resemblance” to O’Loughlin and who told Slattery in an interview that he was “99 percent sure” he had committed the crime.

The man, identified in court as Jeffrey Bartley, is currently incarcerated on other charges. Bartley was convicted of rape in 1985, of open and gross lewdness in 1980 and 1981 and of charges related to child pornography in 2012, according to the Sex Offender Registry Board.

During closing arguments on Monday, Assistant Attorney General Joshua Jacobson said that Slattery suffered from “tunnel vision,’’ choosing to consider only evidence that would fit his hypothesis that O’Loughlin had been misidentified.

The victim was still sure who raped her, Jacobson said. He described how the victim identified O’Loughlin after police found him walking on the side of the road after the rape. She said she wasn’t sure about who he was by his looks but was convinced after asking police to have him speak. “What he said was so horrible and memorable,’’ Jacobson said, that she “immediately knew that was the voice of the man who raped her.”

O’Loughlin had insisted he was at home with his sister at the time of the assault and was heading out on foot to go to a party when he was stopped by police. Kendall argued that Slattery and the Middlesex District Attorney’s office supported O’Loughlin’s quest to re-open his case after a deep-dive investigation, coming to the conclusion they may have erred. “Is that tunnel vision or is that integrity?” he asked.

On Tuesday, O’Loughlin said he can hardly imagine a life without worrying about a knock on the door or a phone call reminding him of his past. He said he was sorry the victim had to explain her ordeal again and that, he believes, she wasn’t given the correct information about what really happened.

“I don’t know what tomorrow is going to be like,’’ he said. “I'm going to fully embrace a life of not being a convicted sex offender.”