The human rights of two patients who died after being infected with hepatitis C through NHS blood products were breached, a judge has found.
Thousands of people in the UK were exposed to hepatitis C
Lord Mackay of Drumadoon has quashed a decision not to hold fatal accident inquiries into the deaths of Eileen O'Hara and Rev David Black in 2003.
He said ministers and the lord advocate had acted in a manner incompatible with their rights.
The families of the two patients involved welcomed the ruling.
The original decision was taken in 2006, under the previous Scottish Executive.
Lord Mackay's judicial review findings, issued by the Court of Session in Edinburgh, also referred to ministers' refusal at the time to hold a full public inquiry into the general issue of infections through health service blood products.
He stated that the lord advocate - Scotland's senior law officer - and Holyrood ministers "acted in a manner incompatible with the convention rights of the deceased" at the time.
The current Scottish Government has pledged to hold a public inquiry into people infected with hepatitis C and HIV from blood products in the 70s and 80s.
The judicial review was raised by Mrs O'Hara's daughter, Rosaleen Kennedy, and Rev Black's widow, Jean, after the victims were infected as a result of receiving blood transfusions.
The ruling pointed out that the Scottish health and blood transfusion services did not begin screening blood donations for the presence of hepatitis C until October 1991.
A summary of Lord Mackay's findings stated: "In the particular circumstances of these cases, Lord Mackay has reached the conclusion that the only means by which a practical and effective investigation into the death of either Mrs O'Hara or Mr Black could be achieved would be if the state were to initiate a public inquiry.
"That could be done by the lord advocate seeking the holding of a fatal accident inquiry before a sheriff or by the Scottish ministers setting up a public inquiry under the provisions of the Inquiries Act."
Lord Mackay has arranged a legal hearing for ministers and the current lord advocate, Elish Angiolini, before making any further orders.
He said that would allow them to consider what action they would take in light of the ruling.
Lawyer Frank Maguire, who represents the families of the dead patients, said: "They have never had an account regarding what happened or why it happened, so they need that as a basic human right.
"They also want, and we need as a society, to have it looked at objectively by someone who is skilled at doing that to see if there are any lessons that we can learn because there are other infections in hospitals, there are other bodies dealing with things and we need to learn if the systems are right and learn the lessons of something that went wrong."
Health Secretary Nicola Sturgeon said: "The decision of the lord advocate in relation to fatal accident inquiries are made independently of government.
"However, the new administration has made clear it is committed to establish a public inquiry.
"We will now study the judgement in detail and in discussion with the Lord Advocate will consider its wider implications."