MPs have voted by a majority of just one vote on a bill designed to force Theresa May to ask for a Brexit extension and avoid the UK leaving the EU without a deal.
MPs supported the European Union (Withdrawal) (No 5) Bill at third reading by 313 votes to 312.
Hartlepool MP Mike Hill voted yes to the bill.
He tweeted after the vote: "The votes tonight were about no to no deal which is consistent with what I’ve always been straight with my constituents about. Equally it’s no to a second referendum and again that’s in line with the majority thinking in Hartlepool."
The draft legislation put forward by former Labour minister Yvette Cooper, which now needs approval by the House of Lords, would force the prime minister to ask the EU for an extension to the Article 50 process beyond 12 April and would give Parliament the power to decide the length of this delay.
It is part of a parliamentary bid to prevent a no-deal departure from the EU.
Tory Brexiteers strongly opposed the measures and, shortly before the final vote, they expressed their frustration at the Bill clearing all stages in the Commons in a matter of hours.
Peter Bone, the MP for Wellingborough, urged Speaker John Bercow to "make this farce stop" and prevent further votes.
But there were cheers in the chamber when the result was revealed at almost 11.30pm, after the legislation passed through all stages in the Commons in a single day.
Speaking after the result Ms Cooper said it has been a "very considered and thoughtful debate throughout", and that MPs had "voted again to make clear the real concerns that there would be about a chaotic and damaging no deal".
She said the Bill would "support the Prime Minister's commitment to make sure we don't end up with no deal on April 12".
Ms Cooper added: "I'm sure that we will be very keen to work with Government to make sure that this legislation progresses in a way that is sensible and works in the national interest."
But Tory MP Mark Francois (Rayleigh and Wickford) reacted to the Bill's passing with anger, calling it a "constitutional outrage".
The leading Brexiteer said it had been "rammed through in four hours", and then quoting from the bible, added: "The public won't be impressed by this. Forgive them father they know not what they do."
The Bill will now undergo further scrutiny in the Lords at a later date, potentially as early as Thursday.
A Government spokesman said in a statement: "We are disappointed that MPs have chosen to back this Bill.
"The Prime Minister has already set out a clear process through which we can leave the European Union with a deal and we have already committed to seeking a further extension.
"If passed, this Bill would place a severe constraint on the Government's ability to negotiate an extension and reflect this new date in UK statute books before April 12."