A man who was found guilty of raping a 13-year-old schoolgirl in a park when he was 17 has had his conviction quashed.
Sean Hogg, 22, was accused of attacking the girl twice in Dalkeith Country Park, Midlothian, in 2018.
Due to new sentencing guidelines for under 25s, he was not jailed and instead sentenced to 270 hours of unpaid work in April.
Mr Hogg’s lawyers argued that Lord Lake had misdirected the jury.
After he won his appeal, prosecutors decided it was not in the public interest to seek a retrial.
At an earlier hearing at the Court of Criminal Appeal in Edinburgh, the Crown Office accepted that the judge had misdirected the jury and part of the verdict should be quashed.
However, the prosecutors argued that the jury still had enough evidence for Mr Hogg to be convicted of raping the girl on a single occasion.
Lord Lake said that if Mr Hogg had committed the crime when he was over 25, he would have been jailed for four or five years.
The judge had said that under new Scottish sentencing guidelines his primary consideration had to be rehabilitation.
His decision not to jail Mr Hogg had attracted criticism the charity Rape Crisis Scotland and other groups.
Mr Hogg, from Hamilton in South Lanarkshire, had been put under supervision and added to the sex offenders register following his conviction.