The case against an Oxford University student who had a rape charge "hanging over his head" for two years has been dropped on the eve of his trial.
Oliver Mears had been on bail since his arrest on suspicion of rape and sexual assault in July 2015, when he was 17.
Mr Mears, now 19, learned prosecutors would offer no evidence after a diary which supported his case was uncovered.
A judge criticised "unnecessary delays" in what the Crown Prosecution Service described as a "finely balanced" case.
Chemistry scholar, from Horley in Surrey, Mr Mears was attending St Hugh's College but suspended his studies amid investigations into the allegations.
The case against him was formally thrown out during a hearing at Guildford Crown Court.
Prosecutor Sarah Lindop told Judge Jonathan Black the decision not to proceed was taken after reviewing the diary and digital evidence.
'Last-minute decision'
The new material "tips the balance" in favour of Mears, she told the court.
Police had been trying to secure the diary, which came into the Crown's possession last week, Ms Lindop said.
"That contains material that was not of assistance to the prosecution."
Reports had suggested Mr Mears' case was among a number of recent high-profile trials dropped over failure to disclose evidence.
Although there were "some disclosure matters", Ms Lindop said, "this is not a disclosure case per se".
The judge criticised "unnecessary delays" in the case, which Mr Mears and the complainant had "hanging over their heads" for two years.
"It seems to me in a case which is as finely balanced as you say it was, there have been unnecessary delays in investigating… leading to what seems to be a completely unnecessary last-minute decision in this case.
"Had the investigation been carried out properly in the first instance, would not have led to this position", he said.
Judge Black demanded the head of the CPS rape and sexual offences unit write to him within 28 days "with a full explanation of what went wrong".
He would then decide whether any action was required "at CPS or police level".
As Mr Mears' mother left court, she said she was "delighted" at the result.
Analysis
By Danny Shaw, BBC home affairs correspondent
Oliver Mears wasn't in court to hear the "not guilty" verdicts, but he'll no doubt be immensely relieved – and heartened to know that the judge was critical about how long it had taken to get to that point.
The reasons for the delay remain unclear, despite the prosecutor's explanation in court.
Cases like this aren't straightforward, but why did it take two years for charges to be brought and a further seven months for evidence to emerge that killed off an already finely-balanced prosecution?
This is the fourth time in four weeks that a rape case has collapsed in such circumstances and it is hard to avoid the conclusion that there is something fundamentally wrong with the system.
"Following a review of this case, prosecutors were not satisfied there was a realistic prospect of conviction," a spokesperson said.
"We therefore decided to offer no evidence."
A file was passed to the CPS in May last year and the decision to charge the student was made the following month.
Surrey Police said it "deeply regrets mistakes made in the efficacy of investigations".
A spokesperson admitted there were "flaws in the initial investigation", during which the victim's digital media went unexamined.
Officers did not follow "what we would consider to be a reasonable line of enquiry", they added,
The force has launched an internal review.
Scotland Yard recently said it would review all sex crime investigations where a suspect had been charged, following the collapse of two rape prosecutions in a week.
The CPS offered no evidence against both Liam Allan and Isaac Itiary after the late disclosure of evidence that could have assisted the defendants.
[contf] [contfnew]
BBC
[contfnewc] [contfnewc]