A man sentenced to four-and-a-half years in prison for rape has had his conviction quashed after his lawyers recovered deleted Facebook messages that seriously questioned his accuser's credibility.
Danny Kay was jailed in late 2013 after a trial at Derby Crown Court.
A woman had accused him of raping her in 2012 after they met on Facebook.
Kay, now aged 26, always maintained his innocence and said the pair had consensual sex, but he was convicted and sent to prison.
Now Kay has had his conviction quashed at the Court of Appeal after his lawyers recovered Facebook messages that supported his version of events.
The woman has since indicated she does not want a retrial.
Appeal judges heard that before the trial police had asked the woman to hand over Facebook messages exchanged between the pair.
Three pages of messages were printed, with the woman telling jurors she had deleted some messages to free up space.
In a ruling published on Thursday (21 December), the three Appeal judges agreed that an "edited and misleading" picture of the Facebook conversation had been presented in court, and that the full exchange, now recovered by Kay from an archived folder, significantly damaged the woman's credibility.
One section of the edited exchange presented to jurors had given the impression Kay had lied about being the same age as her by saying "me too". In fact, he was saying he was also single, the ruling states.
More significantly, the edited Facebook transcript supported the woman's account that the only contact between the pair after the alleged rape had been her expressing concern that she was pregnant.
But jurors never saw messages disputing this account, including one she signed with kisses when she sent her mobile number to Kay after he said it was deleted from his phone.
Another edited exchange shown to the jury during Kay's trial had included him saying "sorry", suggesting to jurors he was apologising for something that had happened between the pair.
"[This] was in fact in response to her asking him why he was ignoring her. Her response, again edited from the jury's version was 'Dnt be'," the Appeal ruling states.
Appeal judge Mr Justice Goss said: "We have come to the conclusion that, in a case of one word against another, the full Facebook message exchange provides very cogent evidence both in relation to the truthfulness and reliability of (the woman) ... and the reliability of (Kay's) account and his truthfulness.
"This further evidence does raise a reasonable doubt as to whether (Kay) would have been convicted had it been before the jury, thus rendering the conviction unsafe."
The case comes after the Met Police this week revealed it was reviewing all current sex attack investigations after two rape trials collapsed when it emerged that crucial evidence clearing the defendants was not disclosed.
Last week, 22-year-old Liam Allan's rape trial was thrown out of Croydon Crown Court after police had withheld thousands of text messages that would have proved his innocence.
One sent by his accuser read: "It was not against my will."
Days later, Isaac Itiary, 25, saw his child rape case also thrown out after concerns were raised over the failure to disclose vital material to prosecutors and the defence.
The incidents came against a background of warnings that police were making basic errors with damaging consequences for alleged perpetrators in a bid to improve sex abuse conviction rates.
Just 11.2% of rape allegations result in a conviction.