The 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.
Defence Minister Guto Bebb resigned so he could vote against the government.
Critics said the amendments 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 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.
What the MPs voted on
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.
Little room for manoeuvre
BBC political editor Laura Kuenssberg
It looks a mess because it is a mess. It’s getting harder and harder for the prime minister to get things through Parliament – and while calls for a second referendum are widely rejected, that sentiment could change if this kind of gridlock continues.
The PM has spent the last two years trying to compromise. She has a divided party and no majority. There are no easy choices.
But the divisions in the Tory party are daily reducing her room for manoeuvre. In a debate about principle, the problem for some is that compromise is a dirty word.
MPs will carry on debating Brexit on Tuesday when a separate piece of legislation, 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.
Brexit: Government scrapes through Customs Bill votes}