MPs have voted to reject a bid by rebel Tory MPs to stop foreign criminals using European human rights law to avoid deportation, by 241 to 97.
But MPs did vote in favour of Home Secretary Theresa May's plan to strip foreign-born terror suspects of UK citizenship, by 297 to 34.
The rebel plan only failed thanks to opposition from Labour and Lib Dem MPs.
No 10 - anticipating a big rebellion - had ordered Tory ministers to abstain rather than oppose the backbenchers.
If, as had been expected at one stage, Labour MPs had also abstained, the rebel amendment would have succeeded.
Dominic Raab - the Tory MP behind the amendment - told MPs it was time the law was changed so foreign criminals could no longer use Article 8 of the European Convention on Human Rights - a right to a family life - to escape deportation.
There was confusion in the Commons as Mrs May sought to attack Mr Raab's amendmen,t just as Downing Street was announcing that ministers were to abstain in the vote.
She told MPs the amendment was "incompatible" with the European Convention on Human Rights.
Shadow home secretary Yvette Cooper accused the home secretary and prime minister of being "scared of their own backbenchers", adding that the Immigration Bill has been a "car crash" for the government.
Downing Street said that David Cameron agreed with the aims of the rebels, but had told ministers to abstain because of fears that the actual measure being proposed could be illegal.