France's National Assembly late Sunday passed a controversial immigration law that has exposed unprecedented divisions in President Emmanuel Macron's young centrist party.
After 61 hours of debate, the measure was approved in a vote of 228 in favour, 139 against and 24 abstentions. It passed largely with the support of Macron's Republic On The Move (LREM) party.
But one LREM deputy, Jean-Michel Clement, rebelled and announced that he was quitting the president's party after casting a no vote on the proposed law.
Opposition to the measure was found across the political spectrum with lawmakers of both the right-wing and leftist parties voting against it, as well as the far-right National Front.
The lower-house of the French parliament was supposed to vote on the bill Friday, but the fractious debate stretched into the weekend due to more than 1,000 amendments proposed by deputies.
More than 200 of the changes were suggested by LREM members as Macron's own lawmakers openly challenged his plans to double the maximum time migrants can be held in detention to 90 days.
The government had defended the bill as balanced, but it has been criticised by rightwingers for being too soft and by leftwingers who see it as repressive.
Interior Minister Gerard Collomb said it aims for "better controlled" immigration, halving the waiting time for asylum applications to six months while also making it easier to deport those turned down as "economic" migrants.
Accepted refugees will be given more help to integrate, such as better access to work and French lessons.
Many leftwing opponents lashed out in parliament at measures to keep asylum seekers awaiting deportation, including children, in detention for up to 90 days.
"Nothing justifies locking up a kid," said Socialist deputy Herve Saulignac.
The bill also reduces the time that asylum-claimers have to lodge their application from 120 to 90 days and gives them two weeks to appeal if unsuccessful, which NGOs say is not enough to gather more evidence in support of their claim.
Despite the rumblings of revolt and long debate, the bill had been expected to pass, with LREM holding more than half the seats after battering traditional parties in June's parliamentary elections.
France received a record 100,000 asylum applications last year, bucking the general trend in Europe where the number of asylum seekers halved between 2016 and 2017.
Many Africans and South Asians end up sleeping on the streets of Paris due to a shortage of accommodation, or camping out in Calais hoping to stow away on trucks to Britain.
Controversy over the immigration bill comes as Macron is under pressure for insisting he will push on with sweeping reforms including an overhaul of state rail operator SNCF, despite strikes and street protests.
Monday sees the start of another two days of strikes by rail workers over the shake-up which have been causing havoc for French commuters two days out of five since the start of April.
Rail unions object to plans to strip new SNCF recruits of jobs-for-life and early retirement, part of Macron's bid to reduce the SNCF's nearly 50 billion euros ($61.5 billion) of debt.
The unions are gambling on public opinion turning in their favour but polls suggest an opposite trend, with just 43 percent backing the strike in an Ifop poll released Sunday.
The scale of the disruption has also eased over the course of the month as fewer workers continue with the strike.
On Monday, 35 percent of high-speed trains are set to operate -- up from just an eighth at the beginning of the month.
And air travellers also face disruptions Monday and Tuesday as Air France employees strike for the tenth day in two months.
Nevertheless the French carrier says it expects to maintain 75 percent of its flights on Monday.