A sex attacker who snatched a teenager from a path and carried out a terrifying rape bid fled after women went to her aid.

A judge today praised the actions of members of the public who reacted to the victim's pleas for help and cyclists who pursued Ryan Douglas.

Douglas (25), who was a stranger, attacked the 17-year-old as she was walking in Irvine, in Ayrshire, and held her in a headlock and pulled her by the hair into bushes.

The teenager fought back and a woman who was out with her young son heard her screaming and shouting: "Help me, help me, somebody please help me."

When Christine Herman went to investigate she saw Douglas pushing the victim against a tree with his arm around her neck.

The teenager said: "Please help me I don't know this man."

But Douglas claimed: "She's only joking. It's just a joke."

Advocate depute Rosemary Guinnane told the High Court in Edinburgh: "The victim looked terrified. She was crying and distressed. Her clothing was dishevelled and covered in mud as if she had been involved in a struggle."

Others also responded to her distress and one began dialling 999 for the police prompting Douglas to let go of his victim and flee.

One of the women, Yvonne Lynch, enlisted a passing cyclist, Peter Collier, to pursue the sex attacker, shouting: "Chase him, he's just tried to rape a young girl."

Mr Collier got the help of another cyclist, Gavin McGrath, in the hunt for the attacker and spotted Douglas at an underpass.

Mr Collier grabbed him and shouted that he had captured him to Mr McGrath, but Douglas managed to break free and escaped.

Douglas was detained by police the following day at a house in Irvine where police found him hiding under a pile of clothing in a wardrobe.

He admitted assaulting and attempting to rape the teenager on August 7 last year near to a path at Manson Road, Irvine, when he appeared in court today.

During the attack unemployed Douglas, who has previous convictions for violence, possession of offensive weapons and anti-social behaviour, exposed himself to his victim.

The court heard that Douglas, of Old Caley Road, Irvine, had been drinking following a funeral before going on to a party.

After he left his victim had seen him walking towards her, staggering and smelling strongly of drink.

As she walked on she heard him say: "Just you be careful". She heard someone running behind her and as Douglas reached her he grabbed her neck.

She tried to struggle free but was hauled onto a grassy area and fell. Douglas also fell and released his grip of her and she got to her feet and tried to flee but her attacker grabbed her top.

Miss Guinnane said: "As she tried to escape the accused grabbed hold of her by the hair and pulled her hard causing her to fall onto the ground. She struck her head on the ground as she landed."

He put her in a headlock and began pulling her backwards by the hair into bushes and undergrowth. The victim shouted for help and tried to stop him by digging her heels into the ground.

Douglas told her: "You'd better walk or else." The victim continued to kick and hit out and scratched her attacker who molested her before he fled.

Defence counsel Frances Connor said Douglas had asked her "to express his apology for what must have been a terrifying ordeal for this young girl".

Judge Paul Arthurson QC deferred sentence on Douglas, who is in custody, for the preparation of a background report and put him on the sex offenders' register.

The judge said: "I am very impressed by the actions of all the many members of the public mentioned in the Crown narrative.