A Court of Session judge has ruled that ministers were not legally justified in preventing an islands council from closing four schools last year, causing political embarrassment to Education Secretary Michael Russell.

The ruling immediately prompted rural schools campaigners to call on the Scottish Government to act quickly to address the shortcomings in legislation highlighted by the judge, fearing the door may be open to more school closures.

Mr Russell yesterday said he would pass these matters to the commission currently investigating rural education, which had been due to report in August. It is thought an appeal by ministers is unlikely.

Meanwhile, Western Isles councillors will decide next week whether close Shelibost Primary on Harris and Carloway Primary along with the the S1 and S2 departments at Shawbost and Lionel on Lewis.

These schools were part of a programme of 11 closures agreed by Western Isles Council in November 2010 because falling rolls meant they were no longer viable.

But a year later Mr Russell used his powers under the new Schools Consultation Act to call in the council's decision and prevent the closure of the four schools.

He said the council had failed in its obligation under the act to show that closing these schools was the last resort, or that there were no viable alternatives.

However, the council launched a legal challenge because it had approached all 11 proposed closures in exactly the same way and was unable to understand why seven were deemed properly dealt with, and four not.

Yesterday Lord Brailsford agreed with the local authority. He found several flaws in the Scottish Government's approach, one being that if ministers called in a school closure, they were then obliged to consider each proposal and "determine that matter on its merits", and not just the process.

Lord Brailsford concluded that, despite what ministers had claimed, the council had complied fully with the legislaton.

He said: "In my opinion, in respect of each of the four schools, a fair reading of the various papers produced by the council in order to comply with the statutory steps - leads to the conclusion that they have properly and fairly considered all matters relevant to the closure proposals.

"It follows that I am of the opinion the call-in notices were not justified."

Council leader Angus Campbell was delighted. He said: "The judgment is entirely in the Comhairle's (council's) favour and that is to be welcomed, although it is regrettable that we had to take this action."

But Mr Russell said: "This judgment applies a wider scope to ministerial decision-making than has existed to date, and indicates ministers should look at the merits of school closure, not just the process.

"We will now consider the judgment in detail, and decide on our next step in due course."

Sandy Longmuir, chairman of the Scottish Rural Schools Network, said he was concerned a ruling seemed to mean a closure had to be decided on the specific grounds on which ministers had called it in.

He said: "The act is under review by the commission to see if it is working as Parliament intended, so the act has to be changed to take into account this legal ruling."

But on the west of Harris, where residents have been fighting depopulation for a century, there is concern this may be too late for Shelibost Primary and its six pupils.

Accountant and crofter Neil Campbell told The Herald "This ruling is a bitter blow to us. We have a meeting tonight with six young couples wanting to relocate to West Harris. This certainly does not help our case."