A student at Greenwich University in London was cleared of rape charges filed against him after it was revealed on Wednesday that police officers failed to hand over evidence that proved his innocence.

A judge called for an investigation into the "very highest level" of the Crown Prosecution Service (CPS) and a complete review of how the Metropolitan Police discloses evidence in criminal prosecutions after the screw-up was discovered, the Daily Mail reported.

Liam Allan, 22, spent nearly two years on bail and faced six counts of rape and sexual assault against a "woman who claimed she did not enjoy sex." Allan flatly denied the charges, claiming that the sex was consensual and said she made up the accusations because he was starting to attend college and would not see her again. If convicted, Allan would have spent at least ten years in prison.

Police refused to hand over the woman’s phone records to Allan’s lawyers, claiming that there was nothing relevant to the case in the records and that they would not be needed by the defense or the prosecution.

The break in the case came the day before the trial started when a new prosecuting attorney took over and demanded the police turn over the phone records.

The Mail reports:

A computer disk containing copies of 40,000 messages were taken from the handset, revealing that the woman had continuously pestered the undergraduate for ‘casual sex’.

She also told her friends that she enjoyed sex with him and even spoke about her fantasies of having violent sex and being raped by him.

"I would like to apologize to Liam Allan," prosecuting attorney Jerry Hayes said. "There was a terrible failure in disclosure which was inexcusable."

Following his court appearance, Allan said, "I can’t explain the mental torture of the past two years. I feel betrayed by the system which I had believed would do the right thing – the system I want to work in."