Negotiators worked overtime in Brussels to hash out an agreement, with leaders due to scrutinise any final product at a summit in the EU capital today.
The prime minister could however yet be forced into an extension by parliament after EU member states said it was now too late for leaders to formally sign-off the plan in Brussels. If no agreement is in place by Saturday – when parliament will meet for an extraordinary weekend sitting – the prime minister by law has to ask for a delay.
“The basic foundations of an agreement are ready," European Council president Donald Tusk said on Wednesday evening. "In theory tomorrow we could accept this deal with Great Britain and avoid the chaos and the misfortune linked to an uncontrolled, chaotic exit."
A meeting between Angela Merkel and Emmanuel Macron also ended in optimism, with the French president telling reporters: "I want to believe an agreement is being finalised and that we will be able to endorse it tomorrow."
Characteristically understated, the German chancellor added: "What we heard from Brussels could be worse news, of course. We’re going to wait what Michel Barnier and his team have achieved with British counterparts."
EU27 leaders are today at best expected to give the deal "political" approval and words of encouragement – which may not be enough for MPs back in Westminster.
"I cannot imagine leaders tomorrow being able to say anything more than 'this doesn't look too bad, let's continue to work with the UK to finalise the details'," a senior EU diplomat said on Wednesday, less than 24 hours ahead of the meeting.
"It's clear that there can only be political agreement tomorrow and Friday because we haven't seen any texts: we can't say yes without having done legal scrubbing. It can only be a political yes, we need much more time."
Member states have been kept mostly in the dark about the details of talks so far, with the Commission's team in a "tunnel" with the British side.
"I have no idea where we stand at all because we just don't know. We'll have to see what we get from Michel Barnier," one diplomat said.
"The more the deal is different from what we had prepared early 2018, the more time it will take for legal experts and customs experts to judge. The closer it is to what we had prepared a year and a half ago the easier it will be.
"But it's now clear that is too late to give a formal yes at this European Council. There's just not enough time. We don't need that, we can only give a political yes and come back to it another time."
Sketchy reports from inside the negotiating room were hot and cold all day on Wednesday, with a meeting of EU ambassadors sliding first from 2pm to 5pm, and then finally to 7pm. A planned UK cabinet meeting also slipped back to accommodate the overrunning talks.
Back in Westminster the prime minister addressed his backbenchers at the Tory party's 1922 committee - whose support he needs to pass any plan.
Speaking outside the committee room, Tory MP Bim Afolami said: “To use a mountaineering metaphor, we are at Hillary Steppe. The summit, you can see it but it’s shrouded in cloud. But we can see it, we will get there.”
It's now clear that is too late to give a formal yes at this European Council.
Brexiteer Bernard Jenkin said Tory MPs have been “vindicated” for voting against Theresa May’s deal, as he believed Boris Johnson had “got a different deal”.
“They [the EU] reopened the withdrawal agreement, which under Theresa May they never said they would.”
He claimed there was great support for the PM in the party, but added it would be difficult to back a deal in parliament without seeing the legal text.
The DUP, whose support Mr Johnson also needs, were more enigmatic. During the afternoon leader Arlene Foster slapped down reports that her party had agreed to concessions, snapping an Irish journalist that his EU sources were "talking nonsense".
EU leaders will start arriving in Brussels for this week's summit after lunch on Thursday. The meeting will continue into Friday afternoon, with other items on the agenda including the EU budget, enlargement of the union, and a common response to Turkish military action in northern Syria.
It is expected to be followed by a rare emergency sitting the House of Commons on Saturday, where MPs will discuss the out come of the summit and plot a way forward. Under UK law the prime minister must ask the EU for an extension if no deal has been secured by the Saturday.