The Scottish Executive has been held in contempt of court after mail sent to a notorious murderer was opened by staff at Peterhead Prison.
Beggs is serving a minimum of 20 years in prison
William Beggs, who was convicted of the "limbs-in-the-loch" murder, complained after his post was read.
Scottish ministers had given a previous undertaking that prisoners' mail would not be opened.
No penalty has been imposed by the Court of Session and the executive has indicated it will seek to appeal.
Beggs, 41, originally from Northern Ireland, was found guilty of murdering 18-year-old Barry Wallace following a Christmas works night out in Kilmarnock in 1999.
He is appealing against his conviction, claiming that publicity about the murder made a fair trial impossible.
Beggs is already three years into his life sentence with a minimum of 20 years before he is considered for release.
He picked up the teenager in Kilmarnock, took him back to his flat in the town and sexually assaulted him.
Mr Wallace was murdered and then cut up before his body parts were dumped in Loch Lomond and off the Ayrshire coast.
The ruling arises from a judicial review brought by Beggs in which he complained that "privileged correspondence" from legal advisers was interfered with while in Peterhead.
Pledge to court
He said that his rights under the European Convention on Human Rights had been breached and during proceedings, ministers gave an undertaking that he could receive privileged correspondence unopened.
But Scotland's senior judge, the Lord President, Lord Cullen, has now ruled that the undertaking given to the court about Beggs' correspondence was "not taken seriously enough".
"In our opinion, the Scottish ministers were in contempt of court," he said.
The head of Beggs' victim was found on this Ayrshire beach
"In the circumstances of the present case, we do not consider it is appropriate for us to impose any penalty on them.
"The finding of contempt is of itself a matter of great importance."
Lawyers acting for Beggs wanted the court to order the appearance of one or more ministers.
The judges rejected this but did order the Scottish Prison Service chief executive, Tony Cameron, to appear with the governor of Peterhead.
Beggs' solicitor Tony Kelly said: "This is an important and significant judgement. For the first time, the Scottish ministers or their predecessors have been found in contempt of court.
"It says they are not above the law but I am not rejoicing. I do not think there is anything to be particularly proud of that they were in such flagrant breach of human rights that they committed contempt of court."
A spokesman for the Scottish Prison Service said: "The judgement has wider implications and ministers are seeking leave to appeal.
"The SPS is already acting to improve the system for handling privileged correspondence.
"It consulted in December on new instructions and will be issuing these later this month."