A TEXT from an alleged rape victim that was withheld by police leading to two years of torment for an innocent man said: “It wasn’t against my will”.

The bombshell message revealed during the trial of Liam Allan, 22, has led to calls for an inquiry “at the highest level” into police handling of evidence.

The student has described going through “mental torture” after a rape case against him was thrown out in court because police had failed to hand over more than 40,000 messages from his accuser.

Mr Allan, 22, faced up to ten years in jail charged with six counts of rape and six counts of sexual assault against a young woman over a 14-month period that began when he was 19.

The criminology student at Greenwich University had spent nearly two years on bail and three days in Croydon Crown Court when the trial was stopped in a dramatic fashion after it emerged police officers had failed to hand over evidence that proved his innocence.

The alleged victim had claimed she did not enjoy sex, while Mr Allan claimed it was consensual and she was acting maliciously because he refused to see her after he returned to university.

Officers sat on vital evidence retrieved from the alleged victim that revealed their sex was consensual.

One, sent by the accuser to a female friend on September 3, 2015, read: “It wasn’t against my will or anything”.

Now, the judge has called for an inquiry at the “very highest level” to understand why police failed to hand over critical evidence including 40,000 messages from the accuser to Mr Allan and friends.

The messages showed how she had continually messaged Mr Allan for “casual sex”, said how much she enjoyed it and discussed fantasies of violent sex and rape, The Times reports.

Outside the court, Mr Allan said he went through “mental torture” over the two year period and relied on the system to uncover evidence that would exonerate him.

When first accused, he turned to a local lawyer he had done work experience with and said he was terrified at the idea of going to prison with sex offenders and worried about what would happen to his mum and flatmates when he was away.

“You are all on your own. I could not talk to my mother about the details of the case because she might have been called as a witness. I couldn’t talk with my friends because they might have been called. I felt completely isolated at every stage of the process,” he 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.”

SHOCKING MESSAGES DISCOVERED

The life-changing discovery was made at the 11th hour when a new prosecutor, Jerry Hayes, took over the case one day before the trial began and ordered police to hand over records — including a computer disk that contained 40,000 messages.

Mr Allan’s lawyers had already sought access to the accusers’s telephone records and messages but their requests were denied on the basis there was nothing of interest in them.

Upon discovering the messages, Mr Hayes said he would offer no evidence in court and would like to “apologise” to Mr Allan.

“There was a terrible failure in disclosure which was inexcusable,” he said. “There could have been a serious miscarriage of justice, which could have led to a very significant period of imprisonment and life on the sex offenders register. It appears the officer in the case has not reviewed the disk, which is quite appalling.”

Speaking later, he said detectives had previously told him the sexual messages were “too personal” to share.

“The defence quickly saw the information blew the prosecution out of the water. If they had not been seen this boy faced 12 years in prison and on the sex offenders’ register for life with little chance of appeal. This was a massive miscarriage of justice, which thank heavens was avoided,” he told the BBC.

Judge Peter Gower said Mr Allan was not guilty on all charges.

“There is something that has gone wrong and it is a matter that the Crown Prosecution Service (CPS) in my judgment should be considering at the very highest level,” he said.

“Mr Allan leaves the courtroom an innocent man without a stain on his character.”

Mr Allan’s defence lawyer Julia Smart said she also received details about the text messages the night before she was due to cross examine the accuser, and when she told the court of her findings the trial was scrapped.

Mr Allan’s mum, Lorraine Allan, 46, said the “current climate” means that many people are treated as “guilty until you can prove you’re innocent.”

A spokesman for London Metropolitan Police said: “We are aware of this case being dismissed from court and are carrying out an urgent assessment to establish the circumstances which led to this action being taken.

“We are working closely with the Crown Prosecution Service and keeping in close contact with the victim while this process takes place.”

The Crown Prosecution Service said they will now conduct a “management review” with the Metropolitian Police to “examine the way in which the case was handled.”

Mr Hayes, who is a former Conservative MP wrote in The Times the case marked the most “appalling failure of disclosure I have ever encountered.”

“The CPS are under terrible pressure, as are the police. Both work hard but are badly under-resourced.

“Crown court trials only work because of the co-operation and goodwill of advocates and the bench — but time pressures are making this increasingly difficult.