Theresa May has secured “legally binding” changes to her Brexit deal with the EU, the UK Government said last night on the eve of today’s crunch Commons vote.

European  Commission president Jean-Claude Juncker confirmed that "meaningful legal assurances" have been given over the backstop which the Prime Minister said will mean the so-called Irish backstop will not be permanent.

Theresa May and Mr Juncker unveiled the breakthrough in a joint press conference with the Prime Minister saying: "Today we have agreed legally binding changes that will guarantee that the EU cannot enforce the backstop indefinitely."

Strasbourg talks were focussing on changes to the so-called Irish Sea border backstop, the insurance policy in UK-EU Brexit negotiations to ensure there is no hard border in Ireland. Theresa May is trying to protect Britain from bad faith by the EU in negotiations over the coming two years before a full agreement by keeping the country locked in a permanent backstop.

She confirmed that the changes will be contained in two new documents, a joint legally binding instrument on the withdrawal agreement and a joint statement to supplement the political declaration which will be put to MPs today in the House of Commons.

Ms May said the agreement meant that the backstop "cannot be indefinite, it is only temporary".

HeraldScotland:

"Having an insurance policy that ensures there will never be a hard border in Northern Ireland, is absolutely right," she said.

"It honours the UK's solemn commitments in the Belfast Good Friday agreement. But if we ever have to use that insurance policy, it cannot become a permanent arrangement and it is not the template for our future relationship.

"The deal MPs voted on in January was not strong enough to make that clear, and legally binding changes were needed to set that right. Today we have agreed them.

"A joint instrument with comparable legal weight to the Withdrawal Agreement will guarantee the EU cannot act with the intent of applying the backstop indefinitely.  If they do they can be challenged through arbitration and if they are found to be in breach the UK can suspend the backstop."

She also says alternative arrangements to the backstop will be in place by the end of 2020. 

Mr Juncker said: "We want to preserve peace on the island of Ireland. These are things any responsible politician should care about. We have a deal on the table that does this.

"It compliments the withdrawal agreement without re-opening it."

READ MORE: Brexit: 'Legally binding' changes to deal with EU agreed

He said in the negotiations "we left no stone unturned, our mind has always been open."

HeraldScotland:

It is in this spirit, he says that a "joint legally binding instrument on the withdrawal agreement" has been agreed.

"It provides legal guarantees on the nature of the backstop," he says.

Ms May now hopes this will allow the attorney general Charles Cox to revise his legal opinion, given before the last vote on May’s deal, that the backstop could be in force “indefinitely”.

It is thought that any legalling binding commitment to the temporary basis of the backstop supported by Cox could allow MPs to pass the Withdrawal Agreement today.

It is understood that Mr Cox was "agonising" over what his next step would be.

READ MORE: Brexit: How did MPs react to Theresa May's 'legally binding changes to EU deal' 

It is suggested that the key to a breakthrough was a letter by European Council president Donald Tusk and European Commission president Jean-Claude Juncker on January 14, which stressed that the Withdrawal Agreement does not trump the Good Friday agreement, and some believed if that is turned into legally binding protocol could be grounds for Cox to change his opinion.

The letter from Tusk and Juncker said: "The European Commission can also confirm our shared understanding that the Withdrawal Agreement and the Protocol on Ireland/Northern Ireland do not affect or supersede the provisions of the Good Friday or Belfast Agreement of 10 April 1998 in any way whatsoever; they do not alter in any way the arrangements under Strand II of the 1998 Agreement in particular, whereby areas of North-South cooperation in areas within their respective competences are matters for the Northern Ireland Executive and Government of Ireland to determine."

HeraldScotland: READY TO PLAY HARDBALL? The EU negotiating team will be working under the leadership of Council President Donald Tusk, left, and of the Commission President Jean-Claude Juncker. Should the Scottish electorate be given its own say as soon as the results of

Some legal experts said that meant that if the backstop were to become permanent, it would contradict the Good Friday Agreement as it would replace the Northern Ireland and Republic cooperation with a UK and EU construct.

It was felt by some experts that the UK could use this protocol with the withdrawal agreement to justify getting out of the backstop if it was ever seen to be becoming permanent.

Ms May confirmed that the changes to the agreement "entrenches in legally binding form" that letter.

 READ MORE: What David Lidington told the Commons in bid for breakthrough

The DUP, the Northern Ireland unionist party that props up Mrs May's minority government, said: “These publications need careful analysis. We will be taking appropriate advice, scrutinising the text line by line and forming our own judgement," a DUP spokesman said.

“We will measure this latest text against the Brady amendment, and the commitments made by the Prime Minister on January 29.”

But in the House of Commons shadow Brexit secretary Sir Keir Starmer questioned whether any significant movement changes had been made.

He noted that the minister didn't say that the words of the withdrawal agreement are actually being changed.

"It doesn't sound likely that is going to happen," he says.

But Cabinet Office minister David Lidington, the Prime Minister's de facto deputy, insisted that the withdrawal agreement and the joint instrument "have equal force".

HeraldScotland:

Mr Lidington said the joint legally-biding instrument on the withdrawal agreement could be used to start a "formal dispute" against the EU if it tried to keep the UK tied into the backstop indefinitely.

He added: "The House was clear on the need for legally-binding changes to the backstop. Today we have secured these changes.

"Now is the time to come together, to back this improved Brexit deal and deliver on the instruction of the British people."

Conservative Iain Duncan Smith said the meaningful vote should be pushed back to allow MPs the chance to question the attorney general on the changes.

But SNP Europe spokesman Peter Grant says "the mood of Parliament and the four nations is that this deal cannot go through."

He says the only option is to give Parliament and the people a choice between "this Brexit and no Brexit".

HeraldScotland: Peter Grant MP, Glenrothes and Central Fife

The developments came after Theresa May was in Strasbourg for further talks, while a statement expected at 10pm was put back. The talks came as time was running out for any new assurances or clarifications to the deal which was resoundingly rejected by a 230-vote majority by MPs in January.

The Government must table its motion for Tuesday's debate by the end of the day, alongside the publication of any relevant documents.

MPs have also been promised that they will be shown any updated legal advice from Mr Cox before the debate begins.

Typifying the day’s confusion at Westminster, Ms May's journey was announced by Irish foreign minister Simon Coveney while the UK government was still refusing to confirm it.

There was also an emergency cabinet meeting in Dublin after Taoiseach Leo Varadkar turned around at Dublin airport instead of catching a flight to the US for St Patrick’s Day.

The PM’s entourage, including Brexit Secretary Stephen Barclay, were reported to be optimistic that, with barely a fortnight until Exit day, a workable deal was at hand.

Mrs May’s cabinet, who earlier in the day refused to accept a deal she provisionally agreed with Brussels on Sunday night, were being briefed by her deputy David Lidington.

SNP MP Joanna Cherry QC earlier tweeted that she had heard the UK government was “well on the road to getting enough to get their deal through” the Commons.