Boris Johnson was locked through Tuesday night in a race against time to secure a Brexit deal, after EU chiefs warned him that unless he made new concessions he would be forced to accept an extension to his October 31 exit deadline.

The British prime minister spent the eleventh hour haggling with Arlene Foster, leader of Northern Ireland’s Democratic Unionist party, over a big cash payment for the region to help secure her support for the deal taking shape in Brussels.

One person briefed on the negotiations said the DUP was asking for “billions not millions” for Northern Ireland.

Mr Johnson held a series of meetings with Conservative Eurosceptic MPs and the DUP to persuade them to accept a deal that would impose customs checks on goods entering Northern Ireland.

British negotiators in Brussels were in constant contact with Number 10 to see how far they could go to meet EU demands, amid rising hopes that a deal could be concluded before the European Council meeting starting on Thursday.

The EU-UK talks were continuing in the early hours of Wednesday morning, as both sides worked to thrash out the legal text of a deal.

One EU official said just before midnight on Tuesday that “important matters” were still unresolved. As well as the customs issue, the EU and UK also need a deal on how to give the Northern Ireland Assembly a say in the post-Brexit arrangements — a key British demand.

I am optimistic it is possible to reach a tolerable deal that I am able to vote for © PA

In a crucial breakthrough for Mr Johnson, the head of the hardline Tory European Research Group said a “tolerable” deal could be secured with the EU.

Steve Baker, who helped to vote down Theresa May’s Brexit deal on three occasions, emerged from 80 minutes of talks in Number 10 to declare: “I am optimistic it is possible to reach a tolerable deal that I am able to vote for.”

The DUP, which would have to accept a new customs border on the Irish Sea, told Mr Johnson that its support was contingent on more cash for Northern Ireland. “Clearly it’s going to be a big package,” said one person close to the talks.

Mrs Foster, who entered Downing Street at 7pm on Tuesday night with the DUP’s deputy leader Nigel Dodds, said it was vital that any final deal had the consent of both nationalist and unionist communities.

A DUP spokesperson said Mrs Foster and Mr Dodds met the prime minister in Downing Street for around 90 minutes.

“We respect the fact negotiations are ongoing therefore cannot give a detailed commentary but it would be fair to indicate gaps remain and further work is required,” the spokesperson said.

Mr Johnson has long identified the summit as the crunch moment for Brexit negotiations, and failure to achieve a deal by then would leave him forced by UK law to seek a delay to Britain’s scheduled October 31 departure date.

“This is a moment of political leadership: does the UK want Brexit? If so, the EU is ready to conclude a deal,” said one EU official.

Michel Barnier, the EU’s chief negotiator, is set to brief national ambassadors on progress on Wednesday afternoon. EU officials warn that a deal must be reached by this point for it to be submitted to this week’s summit.

The progress in the UK-EU negotiations after several days of intense work has prompted cautious optimism in Brussels that a deal, considered impossible only days ago, may be within reach.

This contrasts starkly with Sunday evening, when Mr Barnier gave a downbeat assessment to diplomats of Britain’s Brexit proposals.

Since then, the two sides have focused on settling the vexed issue of how to prevent a hard border on the island of Ireland after Brexit, and in particular the need for a watertight proposal for how and where to carry out customs checks.

Mr Barnier on Tuesday morning said a deal in the coming hours would be “very, very difficult but possible”.

EU diplomats said the “landing zone” that had emerged in the talks was one that would keep Northern Ireland inside the UK’s customs territory while ensuring that EU checks and controls were carried out on goods entering the region.

British officials said Mr Johnson’s bottom line was that Northern Ireland had to remain within the UK’s customs territory — to benefit from trade deals struck by the UK — and that the new arrangements had to enjoy the “consent” of the region.

The EU has warned that it will only be able to strike a Brexit deal if it is convinced that the customs system will be resistant to fraud and smuggling within the bloc’s internal market, while Mr Johnson is desperate to minimise how far Northern Ireland is cut off from the rest of the UK.

Weekly podcast Sign up here to the new podcast from Gideon Rachman, the FT’s chief foreign affairs columnist, and listen in on his conversations with the decision makers and thinkers from all over the globe who are shaping world affairs

EU diplomats said talks on Tuesday had focused on how to address EU concerns about possible abuse of the single market, while making sure that businesses in Northern Ireland were not unfairly hit by EU tariffs while still being able to benefit from British trade deals after Brexit.

The plan includes the right for companies to apply for tariff reimbursements, while measures are also being studied to smooth intra-UK trade.

Irish prime minister Leo Varadkar cautioned that, despite the progress in the negotiations, the gap between the two sides on customs was “still quite wide”.

Mr Johnson and French president Emmanuel Macron spoke by phone, with one French official acknowledging “serious British proposals” in recent days.

“There’s the possibility of an agreement . . . But the possibility of an agreement is not an agreement,” said the French official. “Mr Johnson is right to say there’s a possibility, a positive momentum. We are hoping. We are working on it, and it’s possible. But it’s not done.”

Additional reporting by Victor Mallet in Paris and Laura Hughes in London

Copyright The Financial Times Limited . All rights reserved. Please don't copy articles from FT.com and redistribute by email or post to the web.