Nearly 100 MPs - many of them Tory backbenchers - voted today to give ministers rather than judges the final say over whether deportation would breach the human rights of foreign criminals.
Tory MP Dominic Raab's amendment to the Immigration Bill was defeated by 241 votes to 97, a government majority of 144.
However the amendment only failed thanks to opposition from Labour and Liberal Democrat MPs. Downing Street, anticipating a massive rebellion, decided to order Tory ministers to abstain so as not to lose face.
The decision saw the strange spectacle of the prime minister and Tory ministers, including home secretary Theresa May, choosing not to vote against a measure even though the government believed it to be illegal.
Labour said the unprecedented scene of the government choosing not to vote against something even though it opposed it showed ministers were "scared" of their own MPs.
Cameron has sought to minimise the rebellion by stressing he shares his MPs' concerns about the behaviour of the European courts.
Moments before the vote, No.10 said Cameron had a "great deal of sympathy" with Raab and said insisted both the prime minister and those who voted with Raab had a "shared central objective".
More than 200 foreign criminals successfully challenge deportation on human rights grounds every year, with around 90% relying on the ''right to private and family life'' set out under Article 8 of the European Convention on Human Rights.
Raab's amendment would see the home secretary - rather than the courts - have the final say on whether an offender's family links are strong enough to allow them to avoid deportation. Foreign criminals who can prove they face torture, ill-treatment or death in their home country will still be able to overturn deportation orders under separate human rights measures.
He admitted there was a "risk" that the government would face action from Strasbourg, but insisted the measure should not breach human rights rules because of allowances for exceptional circumstances.
Labour's shadow home secretary, Yvette Cooper, seized on Cameron and May's decision to abstain. She told MPs the government was now running "scared" of its own backbenchers.
"The Immigration Bill has been a complete car-crash for the home secretary. The home secretary has become terrified of her own legislation," she said.
Cooper said it was incredible, that the cabinet minister responsible for "enforcing law and order" chose not to "sit on her hands" rather than vote against something that she had said was illegal.
"There is no precedent for this," she said. "She has lost control of her own policy. She was too scared to vote against it. She sat on her hands because she was scared."