The British government has narrowly avoided a defeat on its Customs Bill after agreeing to Brexiteers' demands to change its wording. It twice survived by just three votes after a backlash from pro-EU Tories who accused Theresa May of caving in to the party's Eurosceptic MPs.
Defense Minister Guto Bebb resigned so he could vote against the government.
MPs will carry on debating Brexit on Tuesday when the Trade Bill comes to the Commons. It gives the government the power to build new trade relationships around the world after the UK leaves the EU, and MPs who support staying in the EU's customs union are seeking to change its wording.
Critics said the amendments to the Customs Bill laid down by Eurosceptics on Monday would undermine the UK's recently-announced negotiating position. But Downing Street, which agreed earlier to accept the four amendments, said they were consistent with the White Paper where it sets out how it wants to trade with the EU in years to come.
The UK is due to leave the EU on 29 March 2019 but has yet to agree how its final relationship with the bloc will work. The government, which does not have a Commons majority, has been under pressure from MPs on both sides of the Brexit debate.
This was underlined on Monday as it first accepted a series of demands from Brexiteers who are unhappy at the proposals in the White Paper, believing it keeps the UK too closely tied to the EU.
But this angered MPs from the party's pro-EU wing who refused to back the new amendments, leading to heated exchanges in the House of Commons as the Customs Bill was debated.
Pro-EU MP Anna Soubry suggested backbench Eurosceptic Jacob Rees-Mogg was now running Britain.
This government is in grave danger of not just losing the plot but losing a considerable amount of support from the people of this country unless we get Brexit right, she said.
Another Remainer, former Attorney General Dominic Grieve, said the prime minister had, by accepting the amendments, put herself in a position of considerable weakness. He added that the political system in the country was being torn apart by Brexit and a second referendum may be needed if MPs could not reach a consensus on the issue.
Mr Rees-Mogg said the amendments were broadly in line with government policy, which is why the government accepted them.
By 305 votes to 302 - with 14 Tories rebelling - MPs backed an amendment that prevents the UK from collecting taxes on behalf of the EU, unless the rest of the EU does the same for the UK.
Applying EU tariffs to products destined for the EU is part of Mrs May's plan to avoid friction at UK borders after Brexit. Another amendment, to ensure the UK is out of the EU's VAT regime, was backed by 303 to 300, with a Tory rebellion of 11.
Three Labour MPs voted with the government. The government won several other votes more comfortably, and the entire bill was then approved by the House of Commons by 318 to 285.
The three Labour MPs who rebelled against their party whip by voting with the government were Frank Field, Kate Hoey and Graham Stringer - all of whom are pro-Brexit.
Former Labour MP Kelvin Hopkins who now sits as an independent also supported the government on one of the amendments.
The Conservative rebels were the long-time pro-EU MP Ken Clarke, Heidi Allen, Guto Bebb, Richard Benyon, Jonathan Djanogly, Dominic Grieve, Stephen Hammond, Philip Lee, Nicky Morgan, Robert Neill, Mark Pawsey, Antoinette Sandbach, Anna Soubry and Sarah Wollaston.