MPs have voted by a majority of one to force the prime minister to ask for an extension to the Brexit process, in a bid to avoid any no-deal scenario.
Labour’s Yvette Cooper led the move, which the Commons passed in one day.
It will need Lords approval to become law, while it would be up to the EU to decide whether to grant any extension.
A government spokesperson said it was “disappointed” that MPs backed the bill, which came after Theresa May met Jeremy Corbyn for Brexit talks.
The discussions between the leaders’ sides, which were described as “constructive”, are expected to continue throughout Thursday.
Meanwhile, Chancellor Philip Hammond has suggested that he expects Brussels to insist on a lengthy delay to Brexit and described a public vote to approve any final deal as “a perfectly credible proposition”.
Ms Cooper’s attempts to prevent a no-deal departure from the EU passed by 313 votes to 312.
The draft legislation by the former Labour minister requires Prime Minister Theresa May to table a motion seeking MPs’ approval for an extension to the Article 50 process beyond 12 April to a date of her choosing.
Tory Brexiteers expressed frustration at the unusual process of a backbench bill – the first stage of enacting a law – clearing all stages in the Commons in a matter of hours, rather than months.
The government’s attempt to limit the bill’s powers resulted in a 180-vote defeat – the second biggest defeat for a government in modern times.
Responding to the Commons vote, the government said the bill would place a “severe constraint” on its ability to negotiate an extension to the Brexit deadline before 12 April, the date the UK is due to exit.
The draft legislation will next be considered in the Lords as early as Thursday.
It comes as talks between government negotiators and Labour are set to continue throughout Thursday after Mrs May and Mr Corbyn agreed a “programme of work”.
A No 10 spokesman said on Wednesday that both parties showed “flexibility” and “a commitment to bring the… uncertainty to a close”.
Mr Corbyn said the meeting was “useful, but inconclusive”, adding there had not been “as much change as [he] had expected” in the PM’s position.
The prime minister wants to agree a policy with the Labour leader for MPs to vote on before 10 April – when the EU will hold an emergency summit on Brexit.
But if they cannot reach a consensus, she has pledged to allow MPs to vote on a number of options, including the deal she has negotiated with the EU, which has already been rejected twice by MPs.
In either event, Mrs May said she would ask the EU for a further short extension to Brexit in the hopes of getting an agreement passed by Parliament before 22 May, so that the UK does not have to take part in European elections.
Chris Heaton-Harris quit on Wednesday afternoon, claiming his job at the Department for Exiting the European Union had become “irrelevant” if the government is not prepared to leave without a deal.
Wales Minister Nigel Adams also resigned, saying the government was at risk of failing to deliver “the Brexit people voted for”.
Reports in papers including the Sun suggest as many as 15 more – including several cabinet ministers – could follow if Mrs May strayed too far from previous commitments.
In an interview on ITV’s Peston programme, Mr Hammond suggested the government might have to accept breaching one of the PM’s “red lines” by accepting Labour’s demands for a customs union with the EU.
While the Conservative manifesto had pledged to leave the EU customs union, “some kind of customs arrangement” was always going to be part of the future structure, he said.
Asked about a public vote to confirm approval of the final Brexit deal, Mr Hammond said: “Many people will disagree with it, I’m not sure there’s a majority in Parliament for it, but it’s a perfectly credible proposition and it deserves to be tested in Parliament.”
Mr Corbyn is coming under pressure from senior colleagues in his party to make a further referendum a condition of signing up to any agreement.
Demanding the shadow cabinet hold a vote on the issue, shadow foreign secretary Emily Thornberry said not backing a confirmatory vote would be a “breach” of the policy agreed by party members at its last conference.
The party’s deputy leader, Tom Watson, told Peston that Labour members would “find it unforgiveable” for “us to sign off on Theresa May’s deal without a concession that involves the people”.
However, party chairman Ian Lavery is reported to have warned against the idea, arguing that it could split the party.
European leaders will continue deciding how to respond to Brexit, with Ireland’s prime minister, Leo Varadkar, hosting German Chancellor Angela Merkel in Dublin later.
The UK has until 12 April to propose a plan to the EU – which must be accepted by the bloc – or it will leave without a deal on that date.