UK prime minister Boris Johnson suffered a major Brexit blow Tuesday — losing his majority in the House of Commons and then a vote in Parliament that threatens his vow to leave the European Union next month.

The dramatic day set the stage for a showdown Wednesday — when a cross-party alliance will try to prevent Johnson from taking Britain out of the EU without a deal on Oct. 31, and the PM will push for an early election.

Tuesday began with Johnson’s government losing its Commons majority when one of his own Conservative pols, Phillip Lee, defected to the pro-EU Liberal Democrats.

An alliance of rebel Conservatives and opposition members then won a 328 to 301 vote to seize control of Wednesday’s parliamentary agenda — when they will seek to pass a law forcing Johnson to ask the EU to delay Brexit until Jan. 31, unless he can pass a deal on the terms of the exit.

More than three years after the UK voted in a referendum to leave the EU, Johnson has vowed to pull out of the union at the end of October with or without a deal.

But Johnson’s opponents said they wanted to prevent him playing Russian roulette with a country once touted as a confident pillar of Western economic and political stability.

They argued that nothing can justify the risk of a “no-deal” Brexit that would cut economic ties overnight with Britain’s biggest export market and likely bring huge economic disruption.

The Conservative rebels — who now face expulsion from the party — include Nicholas Soames, the grandson of Britain’s World War II leader Winston Churchill, and two former finance ministers, Philip Hammond and Kenneth Clarke.

Johnson’s government, meanwhile, will seek to hold a vote on Wednesday to approve an early election — most likely for Oct. 14 — which would pit the Brexiteer against lefty Labour leader Jeremy Corbyn.

In the eye of the Brexit maelstrom, however, it was unclear whether opposition parties would support such a move — which requires the support of two-thirds of the 650-seat House of Commons.

Corbyn has long demanded an election as the best way out of the crisis.

But many of those seeking to prevent a “no-deal” Brexit say Johnson could time the poll to ensure that parliament cannot prevent an Oct. 31 departure — with or without a deal.

The Labour Party’s chief enforcer said the party would not let this happen, a source said.

Former Labour Prime Minister Tony Blair on Monday urged Corbyn to avoid the “elephant trap” of an election.

With Post wires