Mr Allan told yesterday how he felt he had been ‘betrayed’ as a result of the handling of the case

The full scale of police ‘incompetence’ that led to an innocent student being put on trial for rape emerged last night as he told how he had been put through ‘mental torture’.

Amid calls for an independent inquiry into the scandal, a series of messages from Liam Allan’s accuser were disclosed, revealing her secret fantasies about being raped and being choked during sex.

Despite telling police she did not enjoy sex, in one text she told friends: ‘You know it’s always nice to be sexually assaulted without breaking the law.’ In another, she pestered Mr Allan, 22, for casual sex.

However, throughout the case, the investigating police officer had refused to hand over the phone messages, telling prosecutors they were ‘too personal’ to share.

It was only when a new prosecutor took on the case and demanded to review the evidence that it was revealed that police had a computer disk of 40,000 text and WhatsApp messages sent by the woman.

His trial was dramatically halted by a judge on Thursday when it emerged that police had failed to disclose evidence of his claims of innocence.

Mr Allan told yesterday how he felt he had been ‘betrayed’ as a result of the handling of the case, spending almost two years on bail and three days in the dock at Croydon Crown Court before the case was stopped.

Last night, MPs demanded an independent inquiry into the handling of the case by both Scotland Yard and the Crown Prosecution Service, and Mr Allan’s mother compared the shambles to a ‘Salem witch hunt’.

Britain’s top prosecutor Alison Saunders, who has continually pushed for more rape prosecutions, was under intense pressure to explain why lawyers did not demand full disclosure of the evidence. Mr Allan, a criminology undergraduate at Greenwich University, had been warned that he could be jailed for at least ten years after being charged with six rapes and one sexual assault.

Last night police and prosecutors were scrambling to explain why the texts were never examined as evidence – even though Mr Allan’s solicitor Simone Meerabux insisted that when her client was arrested he had told police about the messages’ existence

Mr Allan’s solicitor said police were told when he was first arrested in January 2016 that there were incriminating text messages sent by his accuser demonstrating she did enjoy sex, but he was still charged.

Scotland Yard launched an ‘urgent assessment’ of the case, but also admitted last night the detective constable responsible is still on duty working for a sexual offences unit, and has not been suspended.

When the woman, who legally has anonymity for life, first went to police in January last year, she claimed she had been a 16-year-old virgin who didn’t like being intimate with men.

She said the then 18-year-old had raped her six times between September 2014 and August 2015, holding her arms back to prevent her struggling and on one occasion tying her to a bed post and putting a pillow on her face.

She also told detectives he had assaulted her when she had fallen asleep after taking sleeping pills.

But graphic messages recovered from her phone by police when she made the allegations reveal that in fact it was she who pestered Mr Allan for casual sex and was distraught when he rejected her when he went to university.

She wrote: ‘I am so frustrated now there is zero chance of me lasting like nine months without sex? I’m struggling now, how the hell do people go months and months without doing it?’ In other messages, she told friends she was aroused by scenes of rape, saying of one film featuring a sex attack: ‘Sounds like my kind of morning’.

On another occasion she sent a message to a female friend, saying: ‘Well are you going to take me into the park and rape me in the bushes?’ In a separate exchange with a man she said of a film depicting rape: ‘He raped his wife and set fire to her on the street… I love this s***, I’m having a great time.’

Angela Rafferty, QC, chairman of the Criminal Bar Association, said that the failings were ‘not an isolated incident’ and police and the CPS may be ‘unconsciously bias[ed]’ in favour of those who report sex offences.

Last night police and prosecutors were scrambling to explain why the texts were never examined as evidence – even though Mr Allan’s solicitor Simone Meerabux insisted that when her client was arrested he had told police about the messages’ existence.

Yesterday, Miss Meerabux said that prior to the trial, the CPS had told them there was ‘nothing further to disclose’ and it was only after they raised the issue again in court that the officer finally handed over the disk.

Last night a senior barrister claimed the failure to hand over the evidence may be ‘just the tip of the iceberg’

She said: ‘Even once you get past the investigation, the Crown has a continuing duty to review these cases. It has failed throughout. It is essentially two years he can’t regain.

‘It wasn’t just a stress on himself but also the people around him. His mother describes it as a Salem witch hunt.’

Halting the trial on Thursday, Judge Peter Gower demanded an inquiry ‘at the very highest level’ of the CPS. He warned of the risks of ‘serious miscarriages of justice’ after hearing that, to save costs, material was not always handed to defence lawyers.

Mr Allan described how he had been ‘betrayed by the system’ and his mother Lorraine, 46, a bank worker, sobbed as she said her son had been treated as ‘guilty until you can prove you are innocent’.

Julia Smart, who represented Mr Allan, described him as an ‘impeccable young man’, adding: ‘If it can happen to him, it really can happen to anybody if these sort of disclosure exercises are not carried out properly.’ Jerry Hayes, ex-Tory MP and the prosecutor in the case, said: ‘There could have been a very 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 police officer in the case has not reviewed the disk, which is quite appalling. It is sheer incompetence.’ Two months ago Mrs Saunders, the Director of Public Prosecutions (DPP), caused outrage when she said acquittals in rape cases where the victim was drunk don’t necessarily mean that they made a false allegation.

Tory MP Nigel Evans, who was found not guilty of rape in 2014, demanded an independent inquiry – and said Mr Allan should receive compensation.

‘We can’t have the CPS or the police doing any inquiry – it needs somebody totally independent of both bodies,’ he said.

Former justice minister Shailesh Vara said: ‘What has happened in this case is simply unacceptable.

‘There needs to be a thorough investigation, led from the top, by both the CPS and the police to put in place measures to ensure this does not happen again.’

Harvey Proctor, the former Tory MP who was wrongly investigated by the police of historical child sex abuse, said: ‘I believe the DPP and Cressida Dick [head of the Metropolitan Police] should immediately offer a fulsome apology for the horrors he has experienced these past few years.’

Last night a senior barrister claimed the failure to hand over the evidence may be ‘just the tip of the iceberg’.

Dapinder Singh, QC, who specialises in complex frauds and serious crime, told The Times: ‘Disclosure is the backbone of the criminal justice system and a defence team must be able to trust the prosecution to properly discharge their disclosure duties.’

The Met said: ‘We are aware of this case being dismissed and are carrying out an urgent assessment to establish the circumstances. The Met review will be overseen by a Commander. It is in the public interest that a full and thorough review takes place.’

The CPS said: ‘We will now be conducting a management review together with the Metropolitan Police to examine the way in which this case was handled.'