Despite legal misgivings about the measure, the court ruled that the devolved parliament in Edinburgh was entitled to legislate on social policy issues as long as its actions were reasonable and fair.

The judgment follows a long court battle by insurers, led by Axa General, over an act of the Scottish parliament that offered backdated compensation to people with pleural plaques caused by scarring and tissue damage to the lungs from asbestos exposure.

The act was passed even though the House of Lords ruled five years ago that its victims could not claim compensation. The insurers argued that the bill broke provisions on property rights in the European convention on human rights, and constituted unreasonable legal interference.

Although not damaging to health in themselves, the Scottish government said people with pleural plaques were at risk of breathlessness, asbestosis of the lungs, and increased risk of lung cancer and mesothelioma.

The Damages (Asbestos-related Conditions) (Scotland) Act 2009 won cross-party support and is expected to lead to claims of up to £9m against insurers, chiefly by men who have worked in heavy industries such as shipbuilding and train engineering.

The judgment was applauded by Kenny MacAskill, the Scottish justice secretary, who said it was "a triumph for the progressive politics that saw parties unite to do the right thing and help those that have developed pleural plaques as a result of negligent exposure to asbestos.

"We firmly believe that people with this condition should be able to raise a claim for damages, and we are delighted that this decision has gone in their favour – a result that will surely bring them some comfort."

The Scottish Labour leader, Iain Gray, said it was "tremendous news". He added: "This is absolutely the right judgment. It is a victory for common sense and reflects the fact that the move by insurance companies to overturn the will of the Scottish parliament was both unfounded and unjust."

Friends of the Earth Scotland (FoES) was also jubilant, as the ruling also upheld the right of campaign groups to have cases heard in a Scottish court solely on public interest grounds – a proposal MacAskill opposed during the pleural plaques hearing.

The environment group intervened in this supreme court case to challenge very restrictive rules in Scottish courts on who has "title and interest" to take a case under Scots law, a test that rested very heavily on property rights or other private interests.

That restriction was used to prevent Molly Forbes, who lives with her son, Michael, inside the boundaries of Donald Trump's £750m golf resort. The Forbeses have faced pressure to leave, and have taken legal action against Trump and Aberdeenshire council.

Juliet Swann, the head of campaigns at FoES, said the supreme court ruling would put MacAskill under great pressure to implement recommendations that campaigners have greater rights to go to court, which are already well established in England and Wales.

"We are delighted that two of Scotland's most eminent judges have recognised the inequality in the Scots law interpretation of 'standing' and the damaging effect decades of judge-made law has had on the development of public law in Scotland," she said. "It is only right that a judicial ruling should correct the failings of the current system."

The court, which appointed seven judges to consider the case, ruled: "In issues involving questions of social policy [the] court should respect the judgment of the elected body as to what is in the public interest unless that judgment is manifestly without reasonable foundation. It cannot be said that the judgment of the Scottish parliament was without reasonable foundation.

"Therefore the court accepts that the act pursues a legitimate aim. It also considers that the means chosen are reasonably proportionate to the aim sought to be realised."

The case has significant political repercussions after several intense rows earlier this year about supreme court rulings on human rights for prisoners and the rights of suspects to legal representation in Scotland.

Weeks after his landslide Holyrood election victory, Alex Salmond, the first minister of Scotland, and Kenny MacAskill, the Scottish justice secretary, were at the centre of a furious row after they repeatedly attacked the jurisdiction and competence of the court.

They also attacked the two Scottish supreme court judges, Lord Hope and Lord Rodger, regarded in the Scottish legal profession as the most eminent judges of their generation. Rodger was also terminally ill with cancer and unable to defend himself. He died in June, aged 66.

Salmond insisted it was wrong for a London-based court to have jurisdiction over Scotland's separate and distinct criminal and legal system. Many observers believe the attack was motivated partly by anxieties that the supreme court will eventually sit in judgment on the legality of his referendum on Scottish independence.

In its latest judgment, the court acknowledged that while the Scottish parliament had to act legally, it had a democratic mandate.

"The guiding principle is to be found in the rule of law. This is the ultimate controlling factor, and the courts must insist that it is respected by legislation that the parliament enacts," it ruled. "But it would be wrong for the judges to substitute their views as to what is rational or reasonable for the considered judgment of the democratically elected legislature."