Oliver Mears, 19, of Meath Green Lane, was acquitted of two charges on Friday morning (January 19) at Guildford Crown Court after prosecutors offered no evidence against him.
He had been on bail for two years and was due to face trial the following week.
Judge Jonathan Black has demanded prosecutors write to the court to explain why they left it so late to withdraw the case against Mr Mears. They must submit the explanation within 28 days.
Mr Mears, an Oxford University student, had been charged with one count of raping a woman, and another of sexual assault, in July 2015.
The case was passed to the Crown Prosecution Service in May last year, before the decision was made to charge Mr Mears in June 2017.
He appeared in court in August to plead not guilty, and his trial was expected to start next week. However, a CPS spokesman said that a review of the case found there was not a “realistic prospect of conviction”.
Surrey Police has admitted there were “flaws” in the investigation and has launched a review.
Jon Savell, the force’s head of public protection, said: “The CPS have decided to discontinue this trial for a number of reasons after they reviewed the case in January of this year.
“One of these reasons relates to Surrey Police. This is an investigative issue and not related to disclosure [of evidence].
“We accept that there were flaws in the initial investigation. It was not expedient and the investigator did not examine the victim’s digital media during the initial stages of the investigation or follow what we would consider to be a reasonable line of enquiry.”He added: “Surrey Police deeply regrets mistakes made in the efficacy of investigations and will always seek to implement continual improvement and specific learning points.