The discovery horrified Detroit, and the nation: More than 11,000 rape kits were sitting untested in a police warehouse, in some cases gathering dust for decades before prosecutors stumbled upon the boxes in 2009.

One in particular had been collected in November 1997, when a 15-year-old girl came to police with a harrowing tale. After she left a store on Detroit’s east side, she said, a stranger lunged at her. He put a gun to her head and covered her head with a rag, then dragged her into an alleyway, where he raped her. A nurse performed a sexual assault examination, but the evidence went untouched for nearly two decades, until the untested rape kits became a national scandal. In 2015, prosecutors working their way through the backlog finally sent it out for testing.

When James Chad-Lewis Clay, whose DNA came back as a match, was convicted and sentenced to 25 to 50 years in prison, it should have brought the victim some closure. But after the trial ended in 2017, she had a shocking realization: Clay, now 38, was the same person she knew as “Chad” when they briefly dated in high school. The two had a consensual sexual relationship around the same time that she was raped, which accounted for the presence of his DNA. At the time, he would have been 16, and because so much time had passed, she hadn’t recognized him. She was certain the wrong man was behind bars.

On Tuesday, following an investigation by the Detroit Free Press, Clay was released from prison. He’s now waiting on a hearing that will determine his future.

“To be free from this nightmare is amazing,” he told the paper. “It’s the best feeling to be able to go home to my children and my mother. I couldn’t ask for more.”

From the start, Clay insisted he was innocent. He had a felony conviction involving a stolen car, which meant that his DNA was in a national database, and a previous misdemeanor for domestic violence, the Free Press reported. But in August 2017, when police brought him in for questioning, he was adamant that he had never raped anyone, and never owned a gun. He didn’t recognize the victim’s name, or the photo that detectives showed him. When they told him that his DNA had been found inside the victim, he jumped up and smacked the table.

“It’s impossible,” he insisted, according to the Free Press. “I don’t even know this woman. It’s impossible for my DNA to come up in her.”

As the interrogation went on, Clay asked the detectives about the photo that they had shown him. He wanted to know if it had been taken in 1997, when the rape allegedly took place. The detectives didn’t tell him that it had actually been taken far more recently, in 2015. Instead, they said it was the closest they could get. At one point, Clay mentioned that the victim looked slightly familiar, but he was certain that he had never had sex with her.

The victim, likewise, didn’t recognize Clay when shown a recent picture of him as part of a police lineup. But after he was arrested in August 2017, she received legal documents in the mail that listed his full name: James Chad-Lewis Clay. Seeing it suddenly triggered a memory.

“Chad just stuck to me,” the woman, whose name is being withheld because she is a victim of sexual assault, told the Free Press. “Like, I know a Chad.”

The woman called up the officer who was investigating the case to tell him what she had remembered: Back in high school, she had a consensual sexual relationship with another teenager, whose name was Chad. She couldn’t remember his last name, or many details from that period of her life, but she recalled meeting him through a friend named Dion and skipping school with him at his aunt’s house, where he lived.

Clay had been known as Chad his entire life. But when police visited him in jail, he couldn’t confirm what the victim had told them. When questioned by the Free Press years later, he would explain that he had been in “a state of shock,” and his mind had gone blank. He told the detectives that he had never had sex with a woman by the victim’s name and that he lived with his mother, not his aunt, when he was growing up. He also said he didn’t know anyone named Dion. Neither the victim nor the defendant had been shown photos of each other as teens, so they didn’t make the connection.

Less than a week later, as Clay sat in a courtroom for a preliminary hearing, it all came flooding back: The woman sitting across from him was his girlfriend from 20 years ago.

The victim, however, still didn’t recognize him. Even though seeing the name “Chad” had brought back memories, she didn’t realize that the man on the defense stand was her high school boyfriend. Later, she told the Free Press that the experience of reliving her long-buried trauma while testifying in court had been so overwhelming that her focus was elsewhere. Clay’s mother, Ethel Lyons, told WXYZ that she thinks prosecutors and police convinced the woman that there were two different Chads — one was the man she once dated, while the other was the one on trial.

When the case went to trial in November 2017, the victim began hyperventilating as she told jurors about what had happened on the night that the man had pointed a gun at her 20 years before. She was certain about one thing: Chad, her high school boyfriend, hadn’t been the one to rape her in the alley. At the time, she had described her attacker as a black man with a mustache who looked to be about 20 years old and told her that his name was Fred. Twenty years later, she was sure it had been a stranger, and not Chad, because she would have recognized his voice.

But she still hadn’t realized that the man on trial was the same Chad whom she had dated in high school, since they hadn’t seen each other since then — and since she still hadn’t seen an old photo of him. When prosecutors asked her if she had ever had consensual sex with the man on the defense stand, she said no.

Expert witnesses testified that other, unidentified DNA that didn’t belong to Clay had also been found in the rape kit, the Free Press reported. That DNA could have come from a nurse who performed the exam, or even from the victim herself, but the sample was so small that it required specialized testing. A judge assigned to the case denied the defense team’s request to have that testing conducted.

Jurors, who were never told that Clay had identified the victim as his former girlfriend, found him guilty of first-degree criminal sexual conduct. In December 2017, he was sentenced to 25 to 50 years in prison. The slow, terrifying realization of what was happening, Clay wrote to the judge, was like “a drowning feeling with no escape.”

More than a year passed as Clay tried to appeal, with no success. While behind bars, he missed some of his children’s high school graduations, and the birth of his first grandchild, WXYZ reported. It wasn’t until last February that the victim started to believe that she had sent the wrong man to prison. Clay’s mother had hired a private investigator, who took an extra step that police hadn’t: He tracked down a photo of the 38-year-old back when he was a teenager. Then, he showed it to the victim.

“You could see it hit her like a brick wall,” Steve Crane, the private investigator, told the Free Press.

Other details lined up: The Free Press was independently able to track down Dyeon “Dee” McIntyre, who matched the victim’s description of a friend named “Dion” who had introduced her to Chad, and confirmed that the two had dated in high school. They also located Clay’s aunt, who confirmed that her nephew had been “in and out” of her house while he was growing up.

Though the victim wrote a statement in February saying that she didn’t believe that Clay was that the man who raped her, it wasn’t until June, when the Free Press began asking questions, that authorities began to take another look at the case. Last week, on the same day that the paper published its investigation, prosecutors filed a joint motion with Clay’s defense attorney to get him released, writing that new information “seriously calls into question” the integrity of the conviction.

On Monday, the Michigan Court of Appeals ordered Clay’s release, and sent the case back to a lower court that will determine the next steps, and if there will be another trial. In the meantime, he plans to sleep in a real bed, eat his mother’s homemade pork chops, and hug his kids, the Free Press reported.

For the victim, the apparent mix-up has brought more complicated emotions. She told the Free Press that she agreed to pursue criminal charges in 2017 because she hoped it would help her to move past the trauma of her rape, which left her with persistent nightmares and a fear of stepping outdoors at night. But she now wishes that her rape kit was still sitting on the shelf.

“I truly believe in my heart Chad didn’t hurt me,” she said.

More from Morning Mix:

Your at-home DNA test results could be used to solve cold cases

‘Never approach animals’: Video shows 9-year-old girl tossed in the air by charging bison at Yellowstone

A child advocate’s tale of a murderous pedophile ring launched a $2 million probe. It found he was the pedophile.

Ahead of hearing, Trump aims fury at an unlikely target: Mueller aide Aaron Zebley