He was removing his own clothes when others alerted by her screams forced the door open at the Flintshire hostel where he was staying.

The victim was extremely distressed and crying. Nuttall left, saying “I said I was going to do it".

He then changed his clothes, jumped out of a bedroom window and ran off.

Nuttall, of High Street in Holywell – said to have mental health problems – was jailed for three and a half years and ordered to register as a sex offender for life after he admitted sexual assault and false imprisonment in June of last year. A charge of attempted rape, which he denied, was left on the file.

The court heard he had sent her text messages described as intimidating. When she went to use the bathroom, he forced his way in while armed with a knife and locked the door behind him.

He told her to lie down and not to make a sound, threatened her with the knife and she initially thought he was simply going to scare her.

Prosecuting barrister John Philpotts said: “But things took a turn for the worse. He bound her hands with computer cable, he pushed her to the floor, put his hand over her mouth and pointed the knife at her.”

She felt it touch her stomach at one stage.

As she screamed, he pulled her shorts and underwear down, pressed his hand on her mouth harder to try and stop her screaming and menaced her with the knife.

He indecently assaulted her and was removing his own clothes when the door was forced open by a member of staff and another resident.

Judge Niclas Parry said it was a disturbing and very serious matter which took place against a background of intimidation.

He said Nuttall would receive maximum credit for his early guilty pleas. While he had a mental disorder the psychiatric report concluded that it was not appropriate for him to be detained in hospital for treatment.

Judge Parry said however that the defendant’s culpability was reduced by those mental health difficulties.

The case had a sentencing range of six years to 10, the judge warned, but his sentence would be reduced and there would be significant support available for him on his release.

Defending barrister Myles Wilson said the defendant had been neglected as a child, had been in care since the age of two, lived in various care homes and was moved from school to school. He had difficulty maintaining relationships and had no empathy with the other person.

Mr Wilson said: “He was rejected and grossly over-reacted to that beyond all bounds and put this girl through a terrible ordeal."

The defendant had been bullied, had received counselling in custody and had self harmed, but he appreciated that “prison it must be”.

After the case, the Amethyst Team – North Wales Police’s dedicated sexual offences team – welcomed the sentence, adding it was important to send out a strong message that North Wales Police and the courts will not tolerate offences of this nature.

Detective Inspector Kelly Isaacs said this was an horrendous crime.

Amethyst Team provide specialist services to support victims and encourage anyone who has been the victim of a sexual offence to come forward.

If a victim does not feel ready to report to the police then services can be accessed through the confidential Amethyst SARC Helpline on 0808 156 3658.