Theresa May scraped through a crunch House of Commons vote after a Tory Remainer rebellion failed to alter her post-Brexit customs plans.
Winning by just six votes, the government defeated an amendment to its Trade Bill, which was pushed by rebel Conservative MPs, by 307 to 301.
The group of 12 Tory rebels had attempted to commit the government to entering a customs union with the EU, unless an alternative plan for frictionless trade is agreed with Brussels by mid-January.
However, their bid foundered when four Labour Brexiteers staged their own rebellion and sided with the government, which has consistently ruled out entering a customs union with the EU.
The knife-edge result followed a failed last-ditch bid by ministers to appease the Tory Remainer rebels and avoid the dramatic vote.
Pleading directly with rebel leader Stephen Hammond in the House of Commons, trade minister George Hollingbery offered to reflect the Remainers’ demands by changing the bill at a later stage.
Yet, Mr Hammond and the Remainers stood firm and pushed the amendment to a division, with the House of Commons vote accompanied by reports of “awful” threats and “extreme verbal bullying” by Tory whips.
There were also claims MPs were told the prime minister would call a vote of confidence in her premiership, or even a general election, should she be defeated.
In addition, Liberal Democrat MP Jo Swinson, who recently had a baby and was unable to vote, accused the government of breaking a so-called “pairing” agreement.
Under the deal, Ms Swinson claimed Conservative Party chair Brandon Lewis had agreed to also sit out the votes, but he was shown on a division list to have voted on the crucial customs union amendment.
Ms Swinson posted on Twitter: “This is calculated, deliberate breaking of trust by government whips to win at all costs.”
Despite ultimately surviving the Remainer rebellion on the customs union amendment, ministers had earlier been defeated on the Trade Bill when MPs successfully put a legal obligation on the government to negotiate continued participation in the European medicines regulatory network.
MPs backed an amendment proposed by Tory ex-minister Phillip Lee, and supported by a cross-party group of MPs who are also doctors, by 305 votes to 301.
Later, the government was also left embarrassed when it abandoned plans to send MPs on an early summer break, amid ever-deepening divisions among Conservatives on Brexit.
After Labour signalled they would vote against a move to bring parliament’s recess forward by five days – with a number of Tory MPs also expressing their objections to the “idiotic” proposal – the government failed to push forward with the plan.
Tuesday’s rebellions by Tory Remainers were prompted by Mrs May bowing to the demands of Conservative Brexiteers on Monday, when the prime minister accepted their amendments to the government’s separate customs bill.
Dr Lee, who has joined the ranks of Tory Remainer rebels since quitting the government last month in protest at Mrs May’s Brexit strategy, described Monday’s events as “the worst experience I’ve had in politics in eight years”.
He added the prime minister’s appeasement of the European Research Group of Tory eurosceptics had “changed the dynamic” and that he had initially planned to be supportive of Mrs May’s Brexit proposals at the start of the week, before reversing his position.
Tory Brexiteer Andrew Bridgen accused Tory Remainers of coming close to bringing down the government, telling Sky News a defeat for Mrs May “would have triggered a confidence motion in the government immediately”.
“It was a manifesto promise, it’s crucial for Brexit, had that not gone through, where would it have left the government?,” he added.
Asked if Mrs May would have been toppled by a defeat on the crunch customs union vote, Mr Bridgen said: “Obviously that would have been very detrimental to the situation. It could have brought down the government.”
Meanwhile, Labour claimed Conservative splits on Brexit have now left Mrs May “in office, but not in power”.
Shadow international trade secretary Barry Gardiner said: “The government’s handling of Brexit over the past week has been an utter shambles. We have a prime minister who is in office, but not in power.
“Each day that ministers waste arguing amongst themselves increases the risk of the UK crashing out of Europe without an agreement.”
The Government said it would “revisit” the rebels’ successful amendment on European medicines regulation when the Trade Bill comes before the House of Lords.
A spokesman said: “As set out in the White Paper, the UK is seeking participation in the European Medicines Agency.
“We would look to be an active participant and this would involve making an appropriate financial contribution. We will now reflect on this amendment and seek to revisit in the Lords.”
The third reading of the government’s Trade Bill was passed comfortably by 317 votes to 286, with peers now set to scrutinise the legislation.