A sex attacker targeted a lone woman dog walker in Fife but fled after her pets turned on him.

Alexander McIlravie, 26, formerly of Rossend Terrace, Burntisland, knocked the woman to the ground and demanded sex as she tried to fight him off while holding her two dogs on their leads.

The dogs barked loudly and persistently and McIlravie told the woman to release them.But when she let go their leads, they remained beside her, barking at McIlravie.

He then threatened to cut the animals with a blade if she did not silence them.

McIllravie repeatedly punched her on the head as she struggled with him, but the dogs harried him until he fled. He was later found with injuries consistent with dog bites.

The woman later told a court she believed her dogs had saved her from being raped.

Her attacker had denied sexually assaulting her at Burntisland Links on November 11, 2015, with intent to rape her, but was earlier convicted by a jury at Kirkcaldy Sheriff Court.

McIlravie could now face a lifelong sentence after a judge expressed concern that the Crown had chosen to prosecute in the sheriff rather than the High Court.

During the attack, he pinned the woman down and repeatedly stated he intended to have sex with her and that he had a knife.

The woman had gone out on the dark stormy evening to exercise her dogs and became aware of a male running at her who she thought would pass by her.

But McIlravie jumped on her back, forcing her to the ground where he pinned her face down.

After he fled, she phoned her mother who contacted police. The woman said that since the attack she could not go out on her own at night and felt she had lost the freedom to go where she wanted.

Sheriff Alastair Thornton sent the case to the High Court, which has greater powers of sentencing, to consider whether a risk assessment order should be made which can lead to the imposition of an Order for Lifelong Restriction (OLR).

Under an OLR the court imposes a minimum jail sentence to be served but any future release is left to the parole authorities to decide.

When the case was called before Lord Uist at the High Court in Edinburgh on Tuesday, the judge asked: "Why was this case prosecuted in the sheriff court?"

Advocate depute Martin Richardson said the question had occurred to him on considering the papers, but he had been unable to obtain a clear answer in the time available.

Lord Uist said: "Even without the accused's background, an assault of this nature on an innocent woman out walking her dogs would, I would have thought, have merited High Court proceedings."

The judge said it was "a matter of concern" that such a charge was prosecuted in the sheriff court.

He added: "When the case next calls I will require an explanation as to why these proceedings were brought in the sheriff court."

The judge ordered a report of the risk McIlravie poses to the public.

McIlravie, who has previous convictions for assault, will be held in Perth prison while the report is prepared.