The Commons voted 297 to 270 - a Government majority of 27 - to throw out the amendment to the Bill after Peter Lilley, the Secretary of State for Social Security, warned it would have major consequences costing pounds 80m if it were allowed to stand.
"It has been presented as a minor change with minimal consequences. If that were the case I would be happy to accept it. I understand that John McCarthy [the former Beirut hostage] and the Archbishops of Canterbury and Westminster have given it their support but this amendment isn't minor," Mr Lilley said.
It would allow people who had arrived as illegal immigrants some time ago to apply for asylum and claim benefit throughout the appeal system. He argued that there were differences in the law which gave asylum seekers advantages to applying once they had arrived in the country, rather than at the ports.
The move was condemned by Chris Smith, Labour's social security spokesman. He said it would turn a safe haven into a place of wretched destitution. Senior Tory backbencher Sir Patrick Cormack said he could not support the Government because he was so concerned about the measure.
John McCarthy, who has backed the call to allow refugees three days' grace, said: "The suggestion that people who have been abused, and seen friends and relatives similarly abused and even murdered, should be capable at once of addressing bureaucratic minutiae to present a case for asylum, in an alien language, is both cruel and absurd."
Mr Lilley said on BBC radio: "We will take away benefits from those who not only don't claim asylum, but who claim to be something other than asylum-seekers, such as businessmen or tourists who convince the immigration authorities they have the means to support themselves."