LONDON — British Prime Minister Boris Johnson won one vote and lost another in Parliament on Tuesday, a result that inches him closer to his goal of leading Britain out of the European Union — but effectively guarantees it won’t happen on the scheduled date of Oct. 31.

The good news for the prime minister was that lawmakers — for the first time since Britons chose in 2016 to leave the E.U. — voted for a Brexit plan, backing by 329-299 a bill to implement the agreement Johnson struck with the E.U. last week.

But minutes later, legislators rejected his fast-track timetable to pass the bill, saying they needed more time to scrutinize it. The vote went 322-308 against the government.

Johnson responded by stopping the legislation dead in its tracks. He had planned to push it through the House of Commons by Thursday. But he said he would “pause” the legislation until the E.U. had decided whether to agree to delay Britain’s departure.

With the Brexit deadline looming and British politicians still squabbling over the country’s departure terms, Johnson was forced to ask the E.U. for a three-month delay to Britain’s departure date.

He did that, grudgingly, to comply with a law passed by Parliament ordering the government to postpone Brexit rather than risk the economic damage that could come from a no-deal exit.

European Council President Donald Tusk said earlier Tuesday that E.U. leaders “will decide in coming days” whether to grant Britain that extension — what would be the third. French Foreign Minister Jean-Yves Le Drian told French lawmakers Tuesday that he sees “no justification” at this stage for a further delay.

But Tuesday’s votes make it all but impossible for Johnson to fulfill his often-repeated promise to lead Britain out of the E.U. on Oct. 31.

Johnson earlier said he could call a vote on holding a snap general election if Parliament blocked his plans and Brexit was delayed much longer. He hopes an election might break the political deadlock over Brexit that has dragged on for more than three years since British voters opted to leave the E.U.

“I will in no way allow months more of this,” said Johnson, who took power in July vowing that the U.K. would leave the bloc on the scheduled date of Oct. 31, come what may.

“If Parliament refuses to allow Brexit to happen and instead ... decides to delay everything until January or possibly longer, in no circumstances can the government continue with this (bill),” he said.

Last week Johnson struck a divorce deal with the 27 other E.U. leaders, but on Saturday he failed to win Parliament’s backing for it. His only remaining hope of leaving on time was to get lawmakers to pass the Brexit-implementing bill into law before the scheduled departure date, nine days away.

Johnson said backing the bill would allow lawmakers to “turn the page and allow this Parliament and this country to begin to heal and unite.”

The Brexit deal sets out the terms of Britain’s departure, including measures to maintain an open border between the U.K.’s Northern Ireland and E.U. member Ireland. It also enshrines the right of U.K. and E.U. citizens living in the other’s territory to continue with their lives, and sets out the multibillion pound (dollar) payments Britain must make to meet its financial obligations to the E.U.

But the deal does not cover the nitty gritty of future relations between the U.K. and the E.U.: Instead, it confirms a transition period lasting until at least the end of 2020 — and possibly 2022 — in which relations will remain frozen as they are now while a permanent new relationship is worked out.

If Britain leaves the E.U. without a deal, there will be no transition period, uncertainty for millions of citizens and a host of new tariffs, customs checks and other barriers to trade on Day 1. Most economists say that would send unemployment rising, the value of the pound plummeting and plunge the U.K. into recession.

Many lawmakers felt that three days was not nearly enough time for scrutiny of the 115-page bill. Major bills usually take weeks or months to pass through Parliament, giving time for line-by-line scrutiny by lawmakers.

Before Tuesday’s votes, Green lawmaker Caroline Lucas tweeted that lawmakers “had more time to debate the Wild Animals in Circuses Act (affecting 19 animals) than they will to decide the future of 65 million people. It’s hard to think of anything which better illustrates this Govt’s contempt for people, Parliament & democracy.”

After the votes, many lawmakers urged Johnson to push ahead with the bill after securing a delay to Brexit. Opposition Labour Party leader Jeremy Corbyn urged the prime minister to “work with us all of use to agree a reasonable timetable” for its passage.

If Johnson does press ahead with the bill, opposition lawmakers plan to seek amendments that could substantially alter the bill, for example by adding a requirement that the Brexit deal be put to voters in a new referendum, or by requiring the government to extend the transition period until a new trade deal with the E.U. has been agreed.

The government says such major amendments would wreck its legislation, and it would withdraw the bill if the opposition plan succeeds.