THERESA May claims she has secured “legally binding” changes to her Brexit deal that will prevent the Irish backstop becoming permanent.

MPs are set to have their second meaningful vote on the Prime Minister’s agreement tonight. When they first voted on it in January the Tory leader was defeated by 432 votes to 202 - the biggest defeat in Parliament’s history.

In the weeks since, May and her attorney general, Geoffrey Cox, have been trying to get Europe to compromise on the backstop, the safety net that aims to prevent a hard border on the island of Ireland by, in effect, keeping Northern Ireland and the rest of the UK in the single market and customs union.

The initial proposal meant that the only way to leave the backstop is if both London and Brussels agree. Cox, in his legal advice to government and MPs, warned that this could leave the UK trapped in the backstop indefinitely.

His interpretation of May’s new concessions will be crucial to winning over the DUP – who prop up the minority government – and the Brexiteer European Research Group of Tory backbench MPs.

Speaking after late-night, last minute talks, Jean Claude Junker, the President of the European Commission, insisted that regardless of what happened in the Commons tonight there would be no more negotiations.

Yesterday was a day of high drama, chaos and confusion in Westminster. For most the day it seemed as if nobody – not even May’s own MPs or ministers – was entirely sure what was happening.

READ MORE: Poll reveals Scots ready to back independence over any type of Brexit

In the morning it seemed as if negotiations had fallen flat and were now officially dead, leading to suspicions Downing Street might try to postpone today’s meaningful vote.

However, the Tory leader flew to Strasbourg yesterday evening for 11th-hour talks.

The government had until 10.30pm last night to table the motion that MPs will vote on today. At 10.05pm, David Lidington, the de facto deputy prime minister, came to the chamber to give details on what had been agreed.

May’s new package includes a joint interpretative instrument, which acts as a “legal add-on” to the supposedly unchangeable withdrawal agreement.

It will give legal force to the EU’s promise to negotiate an alternative to the backstop, so that it would either never be needed or allow the UK to get out of it as soon as possible.

There is also a "joint legally binding instrument" on the withdrawal agreement which, the Prime Minister, said said could be used to start a "formal dispute" against the EU if it tried to keep the UK tied into the backstop indefinitely.

Bizarrely, it also included a “unilateral statement” from the UK, which would allow the government to set out their own interpretation of the backstop, but one that wouldn’t need be agreed to by Dublin or Brussels.

This would allow the UK to declare that it will be able to walk away if, by the end of the transition period, there is no trade deal and the backstop kicks in, However, if the UK does this, then it’s likely the EU will argue that the backstop is needed, and it will then go to an arbitration panel.

Speaking in Strasbourg, May said: "MPs were clear that legal changes were needed to the backstop. Today we have secured legal changes.

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

READ MORE: McCrone Report author's view on independence is shifting after Brexit

The European Commission’s secretary general, Martin Selmayr, told the ambassadors of the remaining 27 EU member states that they could offer a delay to Britain, but only up to May 23, the day before elections to the European Parliament are due to be held.

He warned, though, that there may need to be a much longer extension if May’s government collapsed.

Speaking in the Commons, Labour leader Jeremy Corbyn said May must put her Brexit deal to the vote.

“Time and time again this prime minister has failed to negotiate, refused to compromise, and delayed and delayed,” he said.

“After three months the prime minister has not achieved one single change to her deal; she is simply running down the clock.”

The SNP’s Westminster leader Ian Blackford said the Prime Minister was “guilty of neglect”.

He told MPs: “In Scotland, businesses, students, farmers, academics, mothers, fathers and EU nationals are rightly worried about their futures, but this Government, this Tory party and this Prime Minister could not care less about the people of Scotland.

“This deal will damage our economy, destroy growth and deprive Scottish people of all the cherished opportunities that the European Union has gifted us.”

Earlier this month, the Prime Minister told MPs that if her deal was rejected, they would get two further votes, firstly tomorrow, on whether they want a no-deal Brexit, and secondly on Thursday, on whether they wanted to delay Brexit.

On the face of it there are not the numbers in the Commons for a no-deal Brexit, and the Prime Minister would face a slew of ministerial resignations if she urged her party to back coming out of Europe with no agreement.