He spent years in prison and decades on a sex-offender registry that branded him with a scarlet letter — all for a rape that he didn’t commit.

After DNA testing in 2016 conclusively proved that Dion Harrell was not the man who had raped a teenage girl back in 1988, prosecutors agreed to vacate the convictions against him. Harrell then applied for compensation that the state makes available for wrongly convicted people.

But the state said he couldn’t get any money — and judges say he’s out of luck.

Harrell’s legal team now plans to appeal to the state Supreme Court, arguing that an unfair technicality is preventing the type of victim that lawmakers had in mind when they set up the compensation fund.

Harrell’s problem is that his exoneration came decades after he was released from prison in 1997.

The letter of the law says that wrongfully convicted people have to apply for the compensation within two years of being released from prison.

Harrell argued that doing that would have been impossible in his case. He was released from prison because his sentence ran out, not because he had been cleared. He said that he was not able to access his DNA evidence until after then-Gov. Chris Christie signed a law in 2015 granting ex-cons the same right as incarcerated defendants to access such evidence.

While the judges seemed somewhat sympathetic to Harrell’s case, they also said that the language of the law was “unambiguous.”

“We have thoroughly considered all of these arguments and reject them as they effectively request that we re-write a clear and unambiguous statute and ignore the Legislature’s clear manifestation that claims like Harrell’s must be filed within two years ‘after his release from imprisonment’ or ‘after the grant of a pardon,’” the judges said in their 21-page decision.

Under that strict interpretation of the law, Harrell had until 1999 to apply for compensation even though his exoneration wouldn't come for another 17 years.

Harrell’s attorney, Glenn A. Garber, said he was surprised by the decision, which he called “a little strange.”

“We do think the Legislature always intended for someone like my client to be compensated,” Garber said.

Even before Tuesday’s decision, lawmakers already were looking to amend the Compensation for Persons Mistakenly Imprisoned Act to allow people to apply after their convictions are vacated, not just after their release or pardon. A proposal is also being considered to allow people who took plea deals to apply for compensation.

Anywhere from 50 to 300 innocent people could be behind bars in New Jersey, according to estimates by the Exoneration Project at Seton Hall University of Law. Since 1977, three dozen people in the state have had their convictions set aside.

Harrell had always maintained his innocence in the 1988 rape case, in which a 17-year-old girl was dragged into a McDonald's parking lot and sexually assaulted and robbed. Harrell said at the time that he had been playing basketball with friends but he became a suspect because he lived next to the restaurant and frequented it and the victim identified him as her attacker. He was sentenced to eight years, which included time for a conviction for an unrelated burglary.

As a result of his rape conviction, he was forced to register as a sex offender. Slip-ups resulted in him getting convicted of violating the registration requirements in 2004 and 2013 — convictions that also were thrown out after his exoneration.

Garber said the registration at times left Harrell unemployed and homeless.

“Being labeled a sex offender, with that on your record, employers avoid you like the plague,” Garber said. “In addition, there’s restrictions on where you could live.”

Two years after his sentences were vacated, Harrell’s legal team applied to the Treasury Department seeking $50,000 for each year he was behind bars and $25,000 for each year he was on the sex-offender list.

The rapist, meanwhile, has not been identified.

Enter your number to get the NJ 101.5 app

Sergio Bichao is deputy digital editor at New Jersey 101.5. Send him news tips: Call 609-359-5348 or email sergio.bichao@townsquaremedia.com.