A judge has criticised police and prosecutors after a rape case against an Oxford University student was dropped just days before his trial.
Oliver Mears, 19, spent two years on bail accused of raping and assaulting a woman in July 2015.
But the Crown Prosecution Service (CPS) decided to offer no evidence against him on the basis of fresh evidence, including a diary that supported his case, which was passed to the CPS just last week.
On Friday, prosecutor Sarah Lindop told Guildford Crown Court the case was "finely balanced" from the start and the new material "tips the balance" in favour of Mears.
Judge Jonathan Black demanded the head of the CPS Rape and Sexual Offences (RASO) unit write to him within 28 days "with a full explanation of what went wrong" before he decides whether any action is required "at CPS or police level".
He said: "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.
"Both Oliver Mears and the complainant have had this matter hanging over their heads for two years in circumstances, had the investigation been carried out properly in the first instance, would not have led to this position."
It comes after Scotland Yard announced a review of every one of its sex crime investigations, where a suspect has 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.
Ms Lindop said: "There were some disclosure matters, but this is not a disclosure case per se. There was a diary produced. Part of that was disclosed, we asked for the full copy of it."
The court heard Mears' lawyers had been asking for the diary since October last year and the prosecutor explained: "The police have been trying to secure that."
"I have been made aware of it coming into the possession of the Crown last week. That contains material that was not of assistance to the prosecution."
She said the diary was not the only reason for the decision, adding: "The situation is we were waiting for third party material, which included matters of a sensitive nature to the complainant in the case.
"We were also awaiting confirmation from the police in terms of the digital devices that were secured."
Surrey Police have launched an internal review of the force's investigation.
A spokesman for the force said: "The CPS have decided to discontinue this trial for a number of reasons.
"Following this decision we, Surrey Police, are undertaking an internal review of our investigation and we will continue to liaise with the CPS following the hearing on Friday."
A file was passed to the CPS in May 2017 and the decision to charge Mears was made the following month.
A CPS spokesman said: "We keep all cases under continual review. Following a review of this case, prosecutors were not satisfied there was a realistic prospect of conviction as the evidential test set out in the Code for Crown Prosecutors was not met. We therefore decided to offer no evidence."