Boris Johnson's prospects of taking Britain out of the European Union by the end of this month were on a knife-edge on Thursday night as he scrambled for support at Westminster for a deal agreed with 27 other leaders.
The European Council agreed unanimously to endorse the deal, which includes plans for a regulatory and customs border between Great Britain and Northern Ireland.
"I am very confident that when my colleagues in parliament study this agreement that they will want to vote for it on Saturday and in succeeding days," Mr Johnson said in Brussels.
The agreement came at the end of a dramatic day that began with the DUP stating it could not support the deal. Less than four hours later, Mr Johnson announced that he had secured "a great new deal that takes back control" and European Commission president Jean-Claude Juncker welcomed the deal soon afterwards.
The deal leaves all but a fraction of the withdrawal agreement negotiated with Theresa May intact, with a new political declaration about the future relationship between Britain and the EU. The Northern Ireland backstop is replaced by a new arrangement under which the North will continue to follow EU regulations on goods.
Northern Ireland will leave the EU's customs union with the rest of the United Kingdom but it will be treated administratively as if it is remaining within it. This means there will be no customs or regulatory border between North and South but some goods moving from Great Britain to Northern Ireland will be subject to checks.
Taoiseach Leo Varadkar described the deal as a new solution that recognised the unique history of Northern Ireland and he paid tribute to the EU's solidarity with Ireland.
“As the leader of a small nation I have felt enormous solidarity from my European partners, and I think [what’s] been demonstrated in the past few years is a union of peoples and one in which small states are protected,” he said.
“I have mixed feelings today, I regret the UK is leaving but respect the decision to do so, like an old friend going on a journey without us, and we really hope it works out for them. There will always be a place at the table for them if they ever want to come back.”
Despite Mr Johnson’s public confidence that the deal can be passed, he faces an uphill battle after the DUP said it would vote against it in a “meaningful vote” in the House of Commons on Saturday.
“These proposals are not, in our view, beneficial to the economic wellbeing of Northern Ireland and the integrity of the union,” the DUP said in a statement.
Mr Johnson declined to comment on whipping arrangements but his allies were on Thursday night wooing some of the Conservative MPs who lost the whip last month as well as hardline Brexiteers. To win a majority without the DUP, Mr Johnson will need the support of some Labour MPs who represent constituencies that voted Leave in 2016.
“It hasn’t always been an easy experience for the UK. It has been long, it has been painful, it has been divisive, and now is the moment for us as a country to come together,” the prime minister said. “Now this is the moment for our parliamentarians to come together and get this thing done, and, as I say, to begin building a new and progressive partnership with our EU friends, with whom, of course, we share so many priorities.”
One senior Irish source said that there was “a bit of déjà vu” about Mr Johnson’s insistence that he could pass the deal.
“He seems to think he can get the numbers,” said another Irish Government source. “Though Theresa May said the same thing.”