THERESA May has avoided disaster on Brexit after a rebel Tory move to keep Britain in a customs union with the European Union was defeated in the Commons by just six votes.

Cheers rang out from Conservative loyalists when the numbers were announced: 301 votes for the rebel amendment and 307 against.

Julian Smith, the UK Government Chief Whip, appeared extremely relieved as he mumbled to colleagues on the Conservative frontbench just seconds before the vote result was read out.

He was said to have threatened to put colleagues on the spot by making clear he would have called a confidence vote in the Prime Minister for today had the Remainer rebels won the key vote.

Mrs May was helped in averting a humiliating reverse thanks to four Labour MPs who sided with the Government; they included Frank Field and Kate Hoey.

Guto Bebb, who quit as a Defence Minister on Monday in protest at Government concessions to the Tory Brexiteers, was among 12 Conservative MPs who rebelled over the customs union plan.

As the PM, throughout yesterday, called in Tory constituency chairmen to Downing Street for a chat, it was also suggested MPs’ minds were being focused with the threat that a defeat for her on such a fundamental issue would have led to an autumn general election.

The rebel amendment would have forced the Government to keep Britain in "a customs union" with the EU unless it could negotiate a "frictionless free trade area for goods" by January 21 next year.

Downing Street made clear this would have breached Mrs May's red line, enshrined in the Chequers Plan, to take Britain out of the customs union to enable it to make trade deals.

Yet, after Mrs May averted defeat by three votes on Monday on tariffs, just minutes before her narrow escape on the customs union issue, the Government did suffer one. MPs voted for continued UK involvement in the EU's regulatory system for medicines by just four votes; 305 votes to 301.

One senior minister observed: “It’s extraordinary that we lost the vote that didn't matter and won the one that did,” before adding: “I don't know where we go from here."

Later, the Trade Bill passed its Third Reading comfortably; 317 votes to 286. It will now go on to the Lords.

Liam Fox, the International Trade Secretary, said the legislation would be "the confident first step that the UK takes towards establishing itself as an independent trading nation for the first time in over 40 years".

But his Labour Shadow Barry Gardiner branded the Government's handling of Brexit an “utter shambles,” adding: “We have a Prime Minister who is in office but not in power.”

Stewart Hosie for the SNP the UK Government had won the key vote “by the skin of its teeth” thanks to Labour’s hard Brexiteers, “who came to the aid of Theresa May; to their shame”.

In a separate development, Sir John Major warned “fanatical" Tory Brexiteers were putting their desire for Brexit before the national interest and could bring down the Government.

The former premier, who campaigned to remain in the EU, said if Westminster rejected any deal the PM struck with Brussels, it could lead to another general election.

On Wednesday, the Brexit tensions will continue as:

*Mrs May faces her last PMQs of the parliamentary session;

*following this, the Commons will debate Britain’s future relationship with the EU – with the possibility of Boris Johnson, the former Foreign Secretary, making a set-piece resignation statement;

*the PM will face senior parliamentarians when she is cross-examined by the Commons Liaison Committee in the afternoon and

*in the evening, she is due to attend the end-of-session meeting of the Tory backbench 1922 Committee.

Meanwhile, the Government abandoned a plan to bring forward Westminster’s summer recess.

After talks with other parties, it was proposed to end the current session tomorrow rather than next Tuesday because of a lack of Government business.

But opposition politicians protested. The SNP’s Pete Wishart said: “It was proposed for one reason and one reason alone and that is to protect the Prime Minister from what looks like her collapsing authority and inability to govern.”