Campaigners have hailed a "landmark" legal ruling they said will improve the protection of alleged victims' human rights within the Scottish justice system.

Rape Crisis Scotland reacted after a court found in favour of an alleged abuse victim who was refused access to legal aid to fight an attempt to obtain her medical records.

The woman - a complainer in a criminal case - was served with legal papers saying her alleged abuser wanted access to all her medical and psychiatric records from 2007 to 2014.

She objected to the man's move, believing that it would infringe her rights under the European Convention on Human Rights (ECHR) to private and family life.

But she was informed that there was no provision in Scotland for legal aid to be granted to enable her to oppose the move in court before a sheriff.

She then applied to Scottish ministers, who have the discretion to grant legal aid, but they refused to make legal aid available.

The woman - who has not been named but is said to be an alleged victim in several charges of assault and domestic abuse - challenged that decision by Scottish ministers in judicial review proceedings at the Court of Session in Edinburgh.

Judge Lord Glennie, who heard the case, today ruled in her favour, setting aside the decision by Scottish ministers.

Lawyers for the ministers argued that the woman had no present right to be heard.

But Lord Glennie stated: "That is wrong."

On the question of whether the woman was entitled to legal aid, the judge went on: "The appropriate course for this court is simply to reduce the decision, founded as it is on an error of law as to the complainer's right to be heard, leaving the Scottish ministers to make a new decision on a correct legal basis. I propose to take that course."

Rape Crisis Scotland, which supported the woman in the judicial review, described it as a key judgment "which improves the protection of complainers' human rights within the Scottish justice system".

They said the decision means a complainer has a right to be told when the person they have accused of assault makes an application for their records; they have a right to be heard on that application, and they are entitled to apply for legal aid to be represented at such a hearing.

The charity has now called on the Scottish Government to put processes in place to make sure that complainers are informed of their rights to oppose applications for their sensitive records.

Sandy Brindley, national coordinator for Rape Crisis Scotland, said the Scottish Government has a strong track record in addressing violence against women but had taken "the wrong approach" on this issue.

"This is a very significant step in improving the protection of complainers' article 8 right to privacy within the Scottish justice system," she said.

"How can it be right that someone is served with legal papers saying their abuser wants to see their medical records but is given no access to legal aid to enable them to oppose it? We consider this to be a serious breach of human rights. This is why we intervened in support of the petitioner in this judicial review."

The Scottish Liberal Democrats said ministers must act immediately to guarantee access to legal aid for any future victims so they can be represented when their records are being sought.

Justice spokeswoman Alison McInnes said: "This is a landmark ruling that is a welcome contrast to the Scottish Government's stance."

It is understood that lawyers working on the woman's case carried out much of the preparatory work for free.

One of those involved, advocate Claire Mitchell, said: "This is a landmark decision in the protection of complainer's human rights in the court process."

A Scottish Government spokesman said: "Scottish ministers are currently considering the outcome of the judicial review and what steps it might take to address the points raised in the decision."