Former cabinet minister David Davis had warned the current law flies in the face of British justice.
Victims of human trafficking, torture, rape, forced prostitution and modern slavery are being locked up rather than helped when they arrive in the UK, he said.
He and other senior Tories, including another former cabinet minister Andrew Mitchell, backed an amendment calling for a 28-day limit on detention to the government’s immigration bill.
Mr Davis told the Commons the UK was the only country in Europe without a limit on the amount of time people can be held.
At the end of last year one person had been held for 1,002 days, he said.
Other amendments designed to continue existing arrangements for unaccompanied child refugees to be reunited with close relatives in the UK, and delay the application of the rules on no recourse to public funds during the coronavirus crisis, were also defeated.
MPs approved the Immigration and Social Security Co-ordination (EU Withdrawal) Bill at third reading by 342 votes to 248, a majority of 94.