Jeremy Corbyn has called on Theresa May to review her "cruel" immigration policy and abandon "bogus" targets in response to the Windrush scandal.
He said the PM had been warned a 2014 law aimed at intensifying the "hostile environment" for illegal migrants would also affect those in the UK legally.
Speaking at PM's questions he called for Home Secretary Amber Rudd to quit.
The PM said Windrush families would get the support they needed but the public wanted action on illegal immigration.
The clash came amid evidence of tensions within the government over policy – the BBC understands Boris Johnson urged Theresa May to introduce an amnesty for illegal migrants in the wake of the Windrush scandal.
Government sources have played down reports of a row between the pair over the issue at Tuesday's cabinet.
- Corbyn: PM 'ignored Windrush warnings'
- Windrush cancer patient gets treatment date
The Windrush cases – which includes anyone who moved to the UK from a Commonwealth country before 1973 – are in the UK legally but some have been threatened with deportation if they did not have paperwork to prove it. The government has set up a task force to help them formalise their status.
Clashing over the row in their weekly Prime Minister's Questions Commons session, Mr Corbyn said Mrs May, when she was home secretary, had been warned by ministers and officials that the 2014 Immigration Act – which required migrants to show paperwork to access services such as healthcare and housing – would have dangerous repercussions.
"These policies swept up British citizens and legal migrants causing them immense suffering, as she was warned," he told MPs.
"Can the PM send a clear message and tell us the hostile environment is over and that her bogus immigration targets that have driven this will be scrapped?"
He called for the 2014 Act and other related legislation – including curbs on legal aid – to be reviewed.
Urging the home secretary to quit, Mr Corbyn said Ms Rudd had "inherited a cruel policy" when she succeeded Mrs May in 2016 and had made it even tougher.
Mrs May rejected claims she was "ignoring" the plight of the families of Caribbean migrants who have had their residency rights questioned, repeating the government's promise they and others from Commonwealth nations who came between 1948 and 1973 would now be offered British citizenship free of charge and would be helped in clarifying their status.
But she said a distinction should be drawn between those people who had settled in the UK legally and contributed to British life and those with no right to be in the UK.
"The Windrush generation are here legally but there are people who are in this country illegally," she said.
"What the leader of the opposition is talking about is illegal immigration and what people up and down the country will tell him is that we should deal with illegal immigration."
It had emerged earlier that at their most recent cabinet meeting the foreign secretary was understood to have urged the prime minister to consider a "broader" amnesty for those migrants who may have been in the UK illegally but who have nevertheless played a "constructive" role in society.
He suggested these would be illegal migrants who had been in the UK for between 10 and 15 years but had "an impeccable record", which would mean they had paid their taxes and did not have any criminal convictions.
It is understood Mrs May told Mr Johnson most opinion polls showed that both Remain and Leave supporters backed strong immigration controls.
A government source rejected press reports of a row between the two, saying they had had "a cordial and friendly exchange".
The source added: "What are cabinets for if not to air these sort of issues?"
Mr Johnson first floated the idea of an amnesty for some illegal immigrants when he was Mayor of London.