A council which has been ordered to look again at how much it pays private care homes says it will sound "alarm bells" across local government.
For the second time in a year, Pembrokeshire has been told to look again at the fees it pays.
After a previous court hearing it increased residents' payments from £390 to £464 a week.
Seven care home companies took further legal action which resulted in the High Court ruling.
They disputed the method used by the council to arrive at the figure.
Owners complained they were not receiving enough from the council for each resident they looked after and some faced going out of business.
But Pembrokeshire said it already paid one of the highest weekly rates in Wales.
Mr Justice Beatson sitting at the High Court in Cardiff ruled that Pembrokeshire council did not follow the agreed funding model and that it did not give appropriate consideration to a number of factors while calculating the final figure.
But he rule out retrospective payments which the council said could have cost it around £6m.
There are around 30 private care homes used by the council in the county.
Following last year's ruling the council warned the decision would cost it around £1.5m extra this year.
After the latest court decision the council said in a statement: "Obviously the council is disappointed with the judgment and we need to reflect upon the detail in it.
"The matter will be considered by members in the new year.
"The position in which Pembrokeshire County Council finds itself will set alarm bells ringing throughout local government.
"Across the whole of the UK, adult care is already a service in financial crisis."