Sean Hogg aged 22-years old pled guilty for attacking a girl twice at Dalkeith Country Park in 2018 when he was 17 years-old.
The accused avoided prison after judge Lord Lake consulted Scotland’s new sentencing guidelines for people aged less than 25 years old.
Lawyers who represented Mr Hogg stated that the judge misdirected the jury during the trial and the conviction should have been quashed.
Prosecutors from the Crown Office had then accepted that the Judge misdirected the jury and that part of the verdict should be quashed.
The Crown did however argue that the jury heard enough evidence for Hogg to be convicted of rape.
Due to sentencing guidelines he was not jailed but received 270 hours of unpaid work instead. The accused was also placed on the sex offender’s register for three years and was put under supervision.