BRITAIN took a step back from the cliff edge yesterday after Theresa May managed to broker a compromise that pleased Ireland, Northern Ireland, the EU and her own fanatical Leave-supporting ministers.

That agreement, critics claimed, came from the Tory leader backing down on just about every British demand, but it does now pave the way for the second round of talks to begin.

The UK will pay a “divorce bill” of somewhere between £35 billion and £39bn, lower than predicted but more than May had wanted.

READ MORE: PM is warned the biggest challenge – on transition and trade – is yet to come

EU citizens in Britain will be allowed to remain in the country, with the European Court of Justice having jurisdiction over their rights for eight years after the withdrawal day.

But for May, the biggest circle to square was the demand from the DUP that there be no difference between what happens in Northern Ireland and in the rest of the UK, while at the same time respecting EU demands to prevent a hard border with the south.

It’s been a difficult week for the Prime Minister.

The deal was ready to be signed, sealed and delivered on Monday until DUP leader Arlene Foster blocked it at the last minute, fearful that Britain was giving up Northern Ireland by agreeing to give the north regulatory alignment with the south, but not with the mainland UK. Foster said such a deal would have led to “special status” for Northern Ireland and a “red line down the Irish Sea”.

The draft agreement published yesterday contained a new paragraph that was added at the request of the Ulster unionists, committing to no “new regulatory barriers” between Northern Ireland and the rest of the UK.

Northern Ireland would also continue to have “unfettered access” to the UK internal market.

And any post-Brexit trade deal agreed between Britain and the EU will only be agreed to if both the UK and the EU believes it protects “North-South co-operation and avoids a hard border.”

The text of the agreement adds: “Should this not be possible, the United Kingdom will propose specific solutions to address the unique circumstances of the island of Ireland.

“In the absence of agreed solutions, the United Kingdom will maintain full alignment with those rules of the internal market and the customs union which, now or in the future, support North-South cooperation, the all-island economy and the protection of the 1998 Agreement.”

Effectively, if London and Brussels can’t agree, and Britain can’t come up with any workable solutions, then the UK will be forced to mirror EU regulations.

Ultimately that means staying in the customs union and the single market without actually being in the customs union and single market – a soft Brexit. Or at the very least a softer Brexit.

There was some talk of it being the end of Brexit altogether.

Arron Banks, the millionaire founder of the Leave.EU campaign, who has donated more than £10 million to Eurosceptic causes in recent years, wasn’t happy.

He said the agreement amounted to a “betrayal” by a “traitorous, lily-livered embarrassment of a Prime Minister”.

In Dublin, the deal was greeted as a huge victory for Taoiseach Leo Varadkar.

European Commission president Jean-Claude Juncker said the agreement meant “significant progress” had been made .

May and Brexit Secretary David Davis flew to Brussels in the middle of the night when it looked like all sides were happy.

So tense were the discussions that the Number 10 Christmas Party, happening on Thursday night, had to be relocated.

In the Brussels press conference yesterday morning May said the process of arriving at a withdrawal deal “hasn’t been easy for either side”, but the agreement represented a “significant improvement” on Monday’s text.

Provisions on citizens’ rights would allow EU nationals in the UK “to go on living their lives as before”, while the financial settlement would be “fair to the British taxpayer” and the agreement on Ireland would guarantee there would be “no hard border” between Northern Ireland and the Republic.

“I very much welcome the prospect of moving ahead to the next phase, to talk about trade and security and to discuss the positive and ambitious future relationship that is in all of our interests,” said May.

Juncker said Brexit was a “sad” development, but added: “Now we must start looking to the future, a future in which the UK will remain a close friend and ally.”

European Council president Donald Tusk confirmed he has sent the EU27 proposed guidelines for a new mandate for chief negotiator Michel Barnier to begin discussions on the transition period, as well as “exploratory talks” on the trade relationship.

“While being satisfied with today’s agreement, which is obviously a personal success for Prime Minister Theresa May, let us remember that the most difficult challenge is still ahead,” Tusk said.

“We all know that breaking up is hard, but breaking up and building a new relation is much harder.

“Since the Brexit referendum, a year and a half has passed. So much time has been devoted to the easier part of the task, and now to negotiate the transition agreement and the framework for our future relationship we have de facto less than a year.”

Under his proposals, during the transition period of around two years after March 2019, the UK would be required to respect EU law – including any new laws passed by the EU27 without British involvement – and to observe its budgetary commitments and the judicial oversight of the ECJ.