A council will have to pay higher fees for residents at four private care homes, a court has ruled.
Pembrokeshire County Council had refused to raise the £390 weekly fee it currently pays for each resident it funds at the care homes.
But the High Court ruled in favour of the care homes and the council will now have to pay higher fees.
A council spokesperson said the authority would review the payments made to the homes.
The council was also criticised in the High Court judgment for failing to have a strategic plan in its provision of care and social services.
It has been ordered to come up with a new fee by 31 January.
Eighty six people live at Pen-coed care home in Saundersfoot, Langton Hall in Fishguard, Woodfield in Narberth and Woodland Lodge, in Tenby.
Care home managers Mike Davies and Susan Mason say they were relieved by the judgment.
They had previously asked the council to increase the funding from £390 per week per resident to £480.
Mr Davies said: "Our over-riding concern from the outset has been the need to provide high quality, sustainable services for the people for whom we provide care.
"The judgement has therefore come as a huge relief for all concerned, most importantly for the residents of the four homes involved in this case and the dedicated staff who look after them.
"When the council come to consider re-setting the fees by the end of January we hope that they are set at a level that enables the homes to carry out essential repairs and to plan for the future, safeguarding high quality care homes for the people of Pembrokeshire."
The managers of the care homes had previously said they faced closing before Christmas due to the lack of funds.
During the hearing, the local authority admitted it had made a mistake in the level of payments made to the homes but had since corrected this error.
A Pembrokeshire County Council spokesman said: "The council has a limited pot of money and faces difficult decisions on how it spends it particularly in the current financial climate.
"It is a delicate balancing act between providing an acceptable level of care to the residents of the homes while at the same time acknowledging the limitations of the public purse.
"Today's judgment was extremely lengthy and we now need to take time to review it before making any further comments."
Ruth Marks, the Older People's Commissioner for Wales said older people needed to be at the centre of council decision making.
"We are living in tough times financially," she said.
"When there is less money, process and reasoned decision making becomes even more important.
"Older people should not be put in jeopardy by less than robust decision making.
"The Older People's Commission will continue to actively monitor the way in which local authorities and independent providers protect the interests of older people in Wales."
Care Forum Wales, which represents independent care providers, said the four homes had received excellent ratings from the care homes regulator, Care and Social Services Inspectorate Wales (CSSIW) and welcomed the judgement.