The EU and Britain looked to be close to nailing down an elusive Brexit deal late Wednesday, just in time to be submitted to a key European summit.
If a text emerges forming the basis of a legal treaty, Britain could be headed for a managed withdrawal from the European bloc it has been part of for nearly half a century.
Otherwise, the Brexit crisis that has sapped UK politics for the past three years could worsen, and British Prime Minister Boris Johnson could make good on a vow to take his country out of the EU without a deal in two weeks' time.
"I'd like to believe a deal is being finalised," French President Emmanuel Macron said alongside German Chancellor Angela Merkel in southern France as negotiators in Brussels worked frantically.
European sources warned it was not a done deal, with one stressing "talks continue" and another declaring: "There is still no white smoke." "We're almost there," the second one said, adding: "Everything is resolved except the application of VAT in Northern Ireland."
Macron, Merkel and other EU leaders will head to Brussels on Thursday with the aim of deciding whether to give the go-ahead to officials to draw up a final withdrawal treaty with Britain.
But EU negotiator Michel Barnier and European diplomats need to know if Johnson can sell the draft deal at home.
"The basic foundations of an agreement are ready and in theory tomorrow (Thursday) we could accept this deal with Great Britain and avoid the chaos and the misfortune linked to an uncontrolled, chaotic exit," Donald Tusk, president of the European Council, said on Poland's TVN24 news.
In London, Johnson hosted a cabinet meeting at which ministers were told there was "a chance of securing a good deal but we are not there yet and there remain outstanding issues", a Downing Street spokesman said.
Uncertainty also clouded the reception by Johnson's sceptical Northern Irish allies, the Democratic Unionist Party (DUP). He met with them in London for the third time in three days to try to persuade them to support his compromise deal.
The DUP will find it hard to accept a reported offer to allow Northern Ireland to stick to EU customs rules after Brexit, which the EU wants to see to avoid the return of a hard border on the island of Ireland.
DUP leader Arlene Foster scoffed at "nonsense" reports that she is ready to give way.
Irish leader Leo Varadkar, while positive about an outcome, suggested it might take to "the end of this month" to reach a detailed, legal agreement.
Barnier was to brief EU ambassadors late Wednesday. He had insisted a draft deal needed to be ready the same day if it were to go to the European leaders at their summit.
The summit is due to begin on Thursday afternoon, but it is not yet clear when the Brexit portion will come up.
Johnson has promised to take the UK out of the European Union on October 31, with or without a divorce agreement to maintain orderly economic ties with its former partners.
A British government audit, published Wednesday, added weight to fears of a catastrophic economic breakdown in the event of a "no deal" exit, forecasting a 45- to 65-percent cut in cross-Channel trade for up to a year.
Against this background, Brexit Minister Stephen Barclay confirmed to British MPs that Johnson would on Saturday comply with a UK law requiring him to send Brussels a letter calling for a Brexit delay if no deal was found.
But he insisted: "We're committed to leaving... On October 31. We think the best way of doing that is with a deal, to leave in a smooth and orderly way.
"That is why the team are, as we speak, involved in intensive negotiations to do that." Many European officials are pessimistic about the chances of a rapid deal, but none publicly rule it out.
France's European Affairs Minister Amelie de Montchalin said: "Of course it is possible, it has been possible for three years." More intense talks resumed this week after Britain softened its stance on the customs status of Northern Ireland in order to clinch an accord before the summit.
But a marathon late-night negotiating session in the EU's Brussels headquarters brought them to the eve of the meeting with still some distance to go.