Firms in Wales whose staff are treated for asbestos-related illnesses will not be ordered to reimburse the NHS.
The court said Welsh ministers had no right to impose charges to fund the NHS, and insurers should not be given extra liabilities for asbestos exposure which long predated the bill.
The Association of British Insurers (ABI) welcomed the judgement.
"The Welsh Bill would have seen increased insurance premiums for Welsh businesses but no extra compensation for mesothelioma sufferers," said a spokesperson.
"The insurance industry remains committed to doing all it can to help the victims of this terrible disease and would be happy to work constructively with the Welsh Government on this issue, as it does on other public policy."
Pontypridd AM Mick Antoniw, who first proposed the bill, said he was "gutted" at the ruling, having predicted the measure could have raised £1m a year for the NHS in Wales.
The bill had been referred to the Supreme Court by the Welsh government's Counsel General Theodore Huckle following objections from the insurance industry.
The Welsh government said it would give "careful consideration to this judgment".
Presiding Officer Dame Rosemary Butler called for "greater clarity" so everyone understood what laws the assembly could pass.