PM will look to make it third-time lucky by putting her deal to parliament again ahead of EU Council
The Armageddon scenario of a crash-out Brexit in two weeks appears to have been narrowly avoided - but a battle looms in Europe on how long of a reprieve to give the UK.
MPs voted to seek an extension to the Brexit deadline from the EU, the length of which will depend on whether Tory leader Theresa May can get her deal through parliament in a third-time lucky attempt next week.
Last night, frantic talks between the Tory leader's allies and the Democratic Unionist Party (DUP) and the hardline European Research Group (ERG) got under way, and are expected to last all weekend in a bid to see them support the deal next week.
The DUP has signalled that it could back the deal, which was seen as dead just a few days ago.
Revised legal advice is one avenue being pursued as a bid to get the divorce deal over the line. UK Attorney General Geoffrey Cox is said to be redrafting the advice that ultimately killed Mrs May's vote last Tuesday to incorporate the Vienna Convention, which allows for the termination of a treaty if there is a "fundamental change of circumstances".
It is understood that he is looking at whether the issue of the Irish backstop and what it would mean for the withdrawal agreement if it did, as opponents of the deal fear, become permanent.
The attorney general may be prepared to say in updated advice that if the backstop becomes permanent the UK could abandon it and the withdrawal agreement under the Vienna Convention as a permanent backstop would be a "fundamental change".
Both the EU and the UK government have repeatedly said the intention of the backstop is to be temporary, if it is ever invoked, but fears persist among Brexiteers that it could see the UK tied indefinitely to Europe.
It is not clear, however, if the changes to the advice being looked at will be enough, with some in the ERG suggesting it will not go far enough to sway Brexiteers.
Arlene Foster, the leader of the DUP, said that her party is "working very hard" with the UK government so that "we leave the EU with a deal".
She claimed the issue of the backstop had been overplayed and that Northern Ireland has a "very small market".
"We have always said if people have a mind to find those ways to deal with these situations, but unfortunately there has not been a willingness to find the way," she said.
"It is not a huge issue. People have made it into a huge issue, let's be sensible, let's get a deal and let's make it work for everybody."
Meanwhile, the EU has offered to restart efforts this weekend to help Mrs May get the deal through, but also insist that the negotiations are done. One suggestion being floated is offering further clarity on the role Stormont could have in negotiations in the trade deal talks.
Mrs May's performance over the coming days will determine if she attends the EU Council next week with a deal in hand, or if she will be begging for an extension to allow the UK to get its house in order.
If her deal, which has already been defeated twice in the House of Commons, is agreed next Wednesday then she will seek an extension the following day to give her until June 30 to allow Westminster to legislate for the deal to take effect.
However, if the withdrawal agreement is not passed then she will have to petition for a longer extension and the UK will need to participate in the European elections.
European leaders have expressed differing views on the idea of a long extension, but European Council President Donald Tusk suggested a year or more. Taoiseach Leo Varadkar said a longer extension would give the UK time to consider options "like participation in the customs union and single market".
"I think we need to be open to any request they make, listen attentively and be generous in our response," he said.
Ireland is expected to lobby European leaders to help Mrs May secure an extension if she comes to plead for more time.
A two-year extension would mean the UK has to continue paying into the EU budget and would also throw up questions about the type of mandate MEPs would have in Europe.
Sources in Dublin described the potential battle as a "bunfight" over what to give Mrs May if she seeks an extension.