Kris Rorrison, 24, used his weight to pin down his victim in the garden of a flat in Edinburgh’s Tollcross in July this year.

The woman – who now suffers panic attacks, flashbacks and nightmares as a result of the attack – repeatedly screamed at him to stop as he tried to force himself on her.

The 23 year-old’s terrifying ordeal only ended when a neighbour in a nearby block of flats saw what was happening and yelled he was calling the police.

Sign up to our daily newsletter The i newsletter cut through the noise Sign up Thanks for signing up! Sorry, there seem to be some issues. Please try again later. Submitting...

Kris Rorrison carried out the attack in July.

Rorrison, from Muirhouse, appeared for sentence at the High Court in Livingston on Thursday after earlier pleading guilty to attempted rape and a drugs charge.

The “high risk” sex offender was jailed for four and a half years and told he would remain under social work supervision for a further three years following his eventual release. His name will remain on the sex offenders’ register indefinitely.

Passing sentence, judge Lord Mulholland told Rorrison: “In respect of the charge of attempted rape your conduct was deplorable.

“You subjected a young girl who had no prior relationship with you to an appalling attack. You attempted to rape your victim despite her repeated resistance

“You used your physical dominance to pin her to the ground and sought to overcome her resistance.

“The attempted rape took place on a bed of nettles, which confirms to me that you cared nothing for the victim and were only interested in your own sexual gratification.

“Had it not been for the intervention of a member of the public the crime would have been completed.”

The judge highlighted that the victim had sustained bruising to her hip and knees and nettle stings and scratches on the backs of her arms, her back and her ankle.

He added: “The attack has had a profound psychological effect on her. Her personality has been affected. She’s no longer the outgoing person she was before the attack on her.

“She has difficulty in focusing and is withdrawn. She suffers panic attacks, affected moods, flashbacks and nightmares. Your criminal conduct caused this.”

Lord Mulholland told Rorrison that his previous convictions demonstrated “a concerning attitude towards women” and the criminal justice social work report confirmed he posed a “very high risk” of reconviction for sexual and violent offences.

The judge said he considered that the normal licence period was not sufficient to protect the public from serious harm from him and he was satisfied that the test for an extended sentence had been met.

The court heard earlier that Rorrison had been at the same house party as the woman in Tarvit Street and they ended up snorting cocaine and chatting outside in the garden.

Rorrison had started “coming on” to the woman before implying that he wanted sex with her.

He then exposed himself to his victim before forcing her down on a bed of nettles and straddling her.

She tried to fight him off and repeatedly told him “Stop”, “Get off!” and “No!”

She also tried to kick him ­off, but failed because he was “significantly taller and heavier” than her.

Neighbours in surrounding blocks heard her screams and one looked out to see Rorrison with his trousers down and shouted to him that police were being contacted. At this, the accused ran away.

In addition to jailing Rorrison for four years and six months for the rape bid the judge imposed a concurrent nine month sentence for supplying the Class A drug cocaine.

He backdated the sentences to start from 3 July and told the accused the extended sentence meant he would remain under supervision for three years following his release.