A Virginia judge has ordered Edgar Coker’s name removed from a sex offender registry, years after a teen recanted her accusation against him, pictured here in 2011. (Jahi Chikwendiu/The Washington Post)

A Stafford County judge has ordered a Virginia man’s name removed from the state’s sex offender registry and his conviction vacated after the court ruled that he received ineffective counsel from his attorney.

Edgar Coker Jr. was 15 in 2007 when his attorney, Denise Rafferty, advised him to plead guilty to raping a friend rather than risk being sentenced to years in an adult prison. Two months after he went into juvenile detention, the then-14-year-old girl recanted her accusation. Nonetheless, Coker spent 17 months in a juvenile prison and his name was added to the sex offender registry.

But it’s not easy to undo a conviction.

“It took a team of half a dozen attorneys, dozens of law students, a pro bono law firm, a legal aid justice center and two clinics at U-Va. law school,” said Matthew Engle, director of the Innocence Project at the University of Virginia School of Law, which helped Coker.

“And several private investigators,” added Deirdre Enright, the co-director of the clinic.

“It took that team six years,” Engle said, “to undo what happened in 15 minutes in juvenile court.”

Circuit Court Judge Jane Marum Roush ruled that Coker’s court-appointed attorney failed to give him effective assistance because she had done “little or no investigation of the facts of the case” before advising him to plead guilty. Roush cited concerns about Rafferty’s work, including not finding the taped interview with a detective in which Coker said that the girl had invited him into her house and that the sex was consensual and not investigating the accuser’s reputation for honesty.

“The court does not believe Ms. Rafferty’s testimony that [Coker] made a ‘full confession’ to her,” Roush wrote.

Rafferty did not return a call seeking comment. In a July hearing, she told the judge that the family had not cooperated with repeated requests for school records or people who would defend him.

Roush gave Stafford Commonwealth’s Attorney Eric Olsen 60 days to decide whether to re-prosecute Coker. A staff member at Olsen’s office said he had no comment on the case. The assistant attorney general and Coker’s attorneys have 21 days to file an objection to the ruling. A request for comment to the attorney general’s office was not immediately returned Wednesday afternoon.

Enright said that Coker, 22 and living in Orange County, Va., has had trouble getting good jobs because his name is on the list and that his family moved repeatedly to avoid neighbors concerned that he might be a predator. After he was released from detention, he went to high school, where he was a track star. But when he returned to watch a football game after graduation, he was arrested because convicted sex offenders are not allowed on school grounds.

Michele Sousa, the mother of the girl who had accused Coker, said she was very happy “because there’s finally closure — this finally has come to an end.” When her daughter told her that she had lied, “I thought there was some sort of a way to just reverse everything, click the ‘undo’ button and — I didn’t expect to have to go through every court in Virginia and go on and on for years.”

When some of Coker’s attorneys reached him by phone to tell him about the judge’s ruling, he was relieved and pleased, Engle said. “This is all very overwhelming to him, and he is only just now beginning to understand . . . that he’s won, and the end is at least in sight.”