A sex attacker who pounced on two strangers in the grounds of a hospital has been jailed for almost four years.

David Milligan attempted to rape a woman at Edinburgh Royal Infirmary, only stopping when a passer-by heard her terrified screams.

The previous day, Milligan attacked another victim at the hospital as she stood having a cigarette.

On Thursday, Milligan returned to the High Court in Glasgow having previously pled guilty to attempted rape and sexual assault.

Lord Mulholland jailed him for a total of three years and nine months.

Milligan will also be supervised for a further two years upon his release and placed on the sex offenders register for life.

The judge said: "You pled guilty to attacking two women who were strangers to you.

"In the second attack, you tried to violently rape a woman. If a member of the public had not been passing, you would have carried out your intention.

"By your actions, you are a danger to women."

The crimes happened in February this year.

The rape bid occurred after Milligan went up to a 53-year-old woman and stated: "I have not had sex in ages. I saw you and was turned on."

He shoved her onto grass as the victim begged: "Get off me. Please don't kill me."

She tried to fight him off - but Milligan told her: "Shut the f*** up."

The court heard he also threatened to kill her if she did not allow him to have sex.

Milligan suddenly fled after a woman heard the victim shout for help.

The attacker had also struck the day before at the hospital.

A 35 year-old woman was smoking, but walked off after spotting Milligan loitering near her.

Milligan then ran up and struck her on the bottom. He also tried to pull the woman towards him - but she managed to get him away.

The hearing was told this victim had felt "very uncomfortable".

After Milligan was traced, he later denied the attempted rape. He told police: "I would absolutely not do that."

His lawyer Niall McCluskey said Milligan had cried when discussing the crimes and claimed he "did not know what came over him".