The court dismissed an appeal by three London councils - Westminster, Lambeth and Hammersmith & Fulham - against a high court decision that they must provide housing and 'the basic for survival' to asylum seekers who are in need of care and attention while their claims for refugee status are considered.
If the authorities had won their appeal, about two thousand people, most of them in the capital, could have faced the prospect of having to live on the streets.
The appeal judges, headed by the Master of the Rolls, Lord Woolf, upheld a ruling by Mr Justice Collins last October that councils must help people who are denied emergency aid as part of the government's bid to curb bogus asylum applications.
Later Gerry Clore, solicitor for the asylum seekers, welcomed the ruling.
'After one more traumatic year for destitute asulum seekers in this country, I am pleased that one of the most senior judges, the Master of the Rolls, has hopefully put this matter to rest,' he said.
'No civilised society can tolerate a system where people are intended to starve, and the courts have recognised that again and again and again, hopefully for the last time.
'I would hope that the house of lords would refuse any petition for leave to appeal against today's decision because at the end of the day Peter Lilley was warned when he threatened to put these measures through that they would not succeed because they are unlawful.
'The courts have appreciated that, an I am sure the house of lords will.
'There are about 2,000 asylum seekers, most of them in the London area, who would be on our streets and starving if the courts had decided otherwise.'
Mr Justice Collins had said at an earlier hearing that he could not believe parliament intended that someone who was lawfully in the UK as an asylum seeker, even though he had not applied on entry, should be left 'destitute, starving and at risk of grave illness and even death.'
The court of appeal judges agreed with lawyers for the four men, who say they fled from persecution in Iraq, Romania, Algeria and China, that the three London councils would be in breach of their duty under the 1948 National Assistance Act if they stopped providing housing for destitute applicants who could not look after themselves.
The councils had contended that their duty to provide shelter, warmth and food was only to those in need by reason of age, illness, disability or similar circumstances, and not to able-bodied people who simply had no money.
Michael Beloff QC, for the councils, had told Lord Woolf and Lords Justices Waite and Henry that the government, in introducing its benefit restrictions last year, no doubt thought extreme measures were required to frustrate thedesire of bogus asylum seekers to make use of welfare services at the expense of taxpayers.
As a result, many asylum seekers, who were not allowed to work, faced the choice between starvation or being sent back to the country where they claimed to fear persecution.
But that did not justify shifting the burden on to local authorities, he said.
The judges said today that asylum seekers were not entitled to claim automatic local council assistance merely because they lacked money and accommodation.
What they were entitled to claim - as a result of the government's withdrawal of benefits - was that, because of the problems under which they were labouring, they were likely to end up in need of care and assistance.
In addition to the lack of food and housing were to be added their inability to speak the language, their ignorance of this country, and the fact they had been subject to the stress of coming to the UK in circumstances which involved at least a claim to refugee status.
Inevitably, the combined effect of these factors, with the passage of time, would produce one or more of the 'care and attention' criteria laid down by the 1948 Act.
Local authorities could anticipate the deterioration which would otherwise take place in an asylum seekers condition by providing assistance, the judges said.
'They do not need to wait until the health of the asylum seeker has been damaged.'
The judges stressed that it was for the local councils to decide whether people qualified for assistance, but the result of today's decision was that 'at least in the case of some asylum seekers' assistance should be provided.
The local authorities were refused leave to appeal to the house of lords, but plan to petition the Law Lords for leave.
Lawyers for the councils told the judges that Mr Lilley was currently proposing to take at least part of the burden back on to central government funds with retrospective effect, but this still left substantial problems for local authorities.
Government lawyers countered that plans to take back part of the responsibility had not been finalised.
Westminster LBC said later that it was 'dismayed' by the judgement, and added that it should not be expected to shoulder any of the financial burden while its move to appeal to the house of lords was pending.
'Supporting asylum seekers who are without accommodation or means of support is not a duty which should rest with local authorities and is fraught with legal and technical problems,' it said.
'The cost falls on just a few London boroughs and is hugely epxensive.
'Westminster alone will spend around£8m in the next financial year providing support and accommodation for asylum seekers. This is an unacceptable burden as the grant available will certainly not match this level of expenditure.
'The whole matter should be treated as a national issue requiring national solutions. Far more financial help, and definite legal advice, is essential.'