Scotland's most senior judge has criticised Scotland's top prosecutor for her public comments in the wake of the collapsed World's End murder trial.
Lord Advocate Elish Angiolini later defended the Crown's handling of the case in the Scottish Parliament.
In an unusual move the Lord Justice General, Lord Hamilton, said judicial independence was being put at risk.
Ms Angiolini said it was important to make a statement to MSPs on the case, to address public concern.
First Minister Alex Salmond said she was "absolutely right" to make the statement, given the level of interest surrounding that case, while pointing out that the lord advocate was accountable to parliament.
Judge Lord Clarke dismissed the World's End case in Edinburgh against convicted killer and rapist Angus Sinclair, who was accused of murdering two teenage girls 30 years ago.
Lord Clarke said that the Crown had insufficient evidence to proceed.
Christine Eadie and Helen Scott, both 17, were last seen in the World's End pub in Edinburgh and their bodies were found dumped in East Lothian.
Ms Angiolini later told parliament that Crown evidence had established a circumstantial case against Sinclair.
She also supported a change in the law to allow the Crown to appeal certain criminal cases if they were thrown out of court.
Lord Hamilton has now written to the lord advocate, stating that the independence of the judiciary depended on final decisions made by judges being respected.
"If such respect is not afforded, the independence of the judiciary as the final arbiter of legal issues is put at risk," he said.
"An open challenge to the correctness of a final decision does not afford the requisite respect.
"Rather, it tends to undermine for the future the confidence which judges, faced with difficult decisions in controversial cases, can reasonably expect to have that their decisions will not be openly criticised by other organs of government."
Lord Hamilton said the public prosecutor was entitled to her private views on the soundness of legal decisions.
However, he added: "Public criticism in a political forum of particular decisions, especially in controversial and sensitive areas, is in my view inappropriate.
Responding to the letter, the lord advocate said she had endeavoured to stress the independence of the judiciary in her statement, adding: "I do not think I could have gone further expressly to afford greater respect for the final decision of the trial judge in the circumstances."
Ms Angiolini said she considered it necessary to respond to criticism of the Crown's handling of the case, including the issue of evidence which was not led.
"There was an unprecedented interest in the actions of the advocate depute, there were calls for an inquiry and for a statement to be made to the parliament on the Crown's handling of the case," she said.
"It was suggested that the case had damaged public confidence in the criminal justice system.
"I considered that it was important for me to allay public concerns as quickly as possible and that this should be done by a full statement to the parliament."
Speaking at First Minister's Question Time, Mr Salmond dismissed Tory concerns that the lord advocate's role as both a public prosecutor and government adviser presented a conflict of interest.
"Inevitably, in giving that statement and answering questions, the lord advocate is going to put forward the Crown point of view, as indeed was done in open court," said Mr Salmond.
"I don't agree that that should be taken as a direct criticism of a trial judge.
"That is surely a law officer responding to public concern, subjecting herself to parliamentary scrutiny and surely that's how it should be in a democratic age in Scotland."