A man who spent more than two years in jail for a rape he did not commit had his conviction quashed after a relative took only a minute to uncover a series of bombshell Facebook messages – missed by police – that proved his innocence.

In the latest rape case to highlight failings in the criminal justice system, The Mail on Sunday can reveal that the jury at Danny Kay’s 2013 trial was only shown doctored transcripts of crucial Facebook chats between Mr Kay and his accuser.

In an exclusive interview with the MoS, Mr Kay said archived versions of the original messages – proving he had consensual sex with his accuser – were found by his sister-in-law, Sarah Maddison. When she showed the Facebook exchange to the officer in charge of the investigation, he said: ‘How did you know how to find the messages and we didn’t?’

Danny Kay, 26, spent more than two years in jail for a rape he did not commit had his conviction quashed after a relative took only a minute to uncover a series of bombshell Facebook messages – missed by police – that proved his innocence (pictured with sister-in-law Sarah Maddison)

By then, Mr Kay had spent three months in jail. It would be another three years before his conviction was overturned. The Appeal Court heard earlier this month that police relied on an ‘edited and misleading’ account of the Facebook conversation that was given to them by the complainant in the weeks after she claimed she was raped by Mr Kay.

Earlier his month, The Mail on Sunday reported that a rape case against student Liam Allan collapsed after it was revealed that police had withheld vital phone messages from his accuser.

Mr Kay, 26, said: ‘Even now, with the conviction quashed, I still can’t believe that it took years of pain and stress for this nightmare to end. And the terrifying thought is that if the police and justice system could fail me like this, it could happen to anyone.

‘Why didn’t the police check my Facebook account when they had my laptop and login details right from the start? Why did it take my sister-in-law to find the evidence? This isn’t some small matter, this is my life and for the police not to do those basic checks is horrendous.’

Mr Kay said he owed his liberty to a chance conversation with a fellow inmate, who convinced him the Facebook messages he thought were lost were recoverable.

Mr Kay asked Ms Maddison to log in to his account. ‘I couldn’t believe how easy it was to find the messages,’ she said. ‘I’ve just worked in admin all my life and am no social media expert. It only took me a minute to find them so how trained police couldn’t is beyond me.’

Earlier his month, The Mail on Sunday reported that a rape case against student Liam Allan collapsed after it was revealed that police had withheld vital phone messages from his accuser

While he waited for his appeal, Mr Kay remained locked up with sex offenders. He was also made to see a psychiatrist because he was judged to be ‘in denial’ because of his protestations of innocence.

At his trial at Derby Crown Court, Mr Kay’s accuser said there had been little contact between them after sex. The jury was given a misleading impression of a message reading ‘sorry’, which was construed as being about the alleged rape. In fact, it was a response to the woman asking him why he was ignoring her. Also omitted from the version presented to the jury was her response: ‘Dnt [sic] be.’

Another message suggested Mr Kay had lied about his age during their first Facebook conversation. He asks the girl how old she is, to which she replies: ‘Nearly 17.’ He then asks if she’s single and she replies ‘yep’.He says: ‘Same here.’ Yet in the messages shown to the jury, it appears his reply ‘Same here’ is a response to her revealing her age.

In an exclusive interview with the MoS, Mr Kay said archived versions of the original messages – proving he had consensual sex with his accuser – were found by his sister-in-law, Sarah Maddison

More damning are the numerous messages sent after the alleged rape that were deleted by his accuser. In one, Mr Kay asks for her number because he’d lost it. Not only does she readily supply it, she accompanies it with four kisses.

The accuser says: ‘im still here for ya!’ And in a separate message, after the pair had split up, she says: ‘I thought u woulda at least tried to get me back.’

When the new messages were shown to the Appeal Court, the judges ruled that the exchange undermined the woman’s account and supported Mr Kay’s version.

Mr Kay’s case has prompted calls for a national review of all rape investigations and comes after two trials in London collapsed when it emerged that police had failed to disclose crucial evidence that pointed to the defendants’ innocence.

When she showed the Facebook exchange to the officer in charge of the investigation, he said: ‘How did you know how to find the messages and we didn’t?’

Mr Kay, from Derby, was training to be a welder when he met his accuser in 2012. They had friends in common and initially had a conversation on Facebook. It began, innocuously enough, with Mr Kay sending a single-word message – ‘Hey’ – along with two kisses on February 1. Yet it set in motion a sequence of events that almost ruined his life. Mr Kay said: ‘She was very pretty and I really felt there was a connection there.’

The pair met in the Derby area and went for a walk. Two weeks later, they met again, this time at Mr Kay’s house, where they watched a film and later had sex. He characterises the relationship as a casual fling, which petered out almost as soon as it began. ‘She initially mentioned calling it a day because she was getting some messages off an ex-partner of mine and she didn’t want the hassle,’ Mr Kay said. ‘I agreed and she came back with the message about me at least fighting for her.’ He adds: ‘At the time we had sex, she seemed perfectly happy.’ By March 23, they had ceased communicating.

It was six months before his accuser filed a complaint to the police. In September, as he arrived back from a holiday in Spain with his new girlfriend and her family, Mr Kay was arrested at East Midlands airport. He said: ‘It was mortifying being taken away by the police right in front of my girlfriend and her family. At first, I thought there was a problem with something in my luggage but then he said I was being arrested on suspicion of rape.’

For 26 hours, Mr Kay was held in custody and interrogated by officers. He refuted the rape allegations in the strongest terms.

The series of Facebook messages that proved Mr Kay was innocent, found by his sister-in-law

From the outset, he insisted Facebook messages would demonstrate his innocence. He remained calm, believing common sense would prevail. Instead, he was charged and released on bail.

‘I had complete trust in the legal system at the time so thought I had nothing to worry about,’ said Mr Kay. For the next year, buoyed by friends and family, he was convinced his innocence would be established in court. When the week-long trial began, the prosecution presented Facebook messages to the jury as evidence of Mr Kay’s guilt. ‘My jaw dropped. I said to the prosecutor that there were other messages, that the conversations weren’t complete,’ he said. ‘But he got angrier and louder and kept saying, “I put it to you that you raped this girl and now you’re lying to this court.” ’

The Mail on Sunday has seen a witness statement from the officer leading the investigation, saying the messages were obtained by asking the accuser to log in to Facebook and print them off. ‘I made sure that no messages were missed,’ he said. At no point did the officer cross-reference the accuser’s version of the conversation with Mr Kay’s archived messages.

Mr Kay said: ‘Everything fell apart when I was found guilty. In that moment, I lost all faith in the system, and all hope.’ He spent his first few months at HMP Whatton in Nottinghamshire, Europe’s largest prison for adult male sex offenders.

‘Hearing some of the things people have been in for is pretty sick. Some of them are proud of being paedophiles and rapists,’ he said.

‘Looking back, I kick myself for trusting a system that betrayed me. I’d just like to know why it all happened. Why she lied. Why the police didn’t investigate properly. They’ve just taken her word for it. She might as well have written it on a piece of toilet paper and said, “There’s the conversation between us.” ’

Mr Kay’s barrister Philip Rule, said: ‘This is an important victory for justice. This is the tip of an iceberg of failings brought about by chronic and long-term under-resourcing of the criminal justice system.’

Derbyshire Police said: ‘We will be reviewing our investigation to find out whether lessons can be learned.’