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."
There was pessimism a breakthrough would happen Wednesday night, with attention focused on a possible announcement early Thursday -- immediately before the start of the EU summit.
- A deal to avoid 'chaos' -
Macron, Merkel and other European leaders at that gathering in Brussels aim to decide whether to give the go-ahead to officials to draw up a final withdrawal treaty with Britain.
"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.
But EU negotiator Michel Barnier and European diplomats need to know if Johnson can sell the draft deal at home.
One EU source said the putative agreement "is politically fragile in London".
Johnson's sceptical Northern Irish allies, the Democratic Unionist Party (DUP), appeared the most problematic.
The British leader met with them in London for the third time in three days to try to persuade them to support his compromise deal.
But 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 was ready to give way.
Johnson told his cabinet 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.
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.
- 'Committed to leaving' -
The two-day 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."
More intense talks resumed this week after Britain softened its stance on the customs status of its province Northern Ireland in order to clinch an accord before the summit.
An EU diplomatic source told AFP that, under the deal being negotiated, Northern Ireland would remain in the EU's value-added tax (VAT) area to ensure smooth trade with EU member Ireland.
However that would require a new mechanism because the UK will be operating with its own VAT rules.