EU leaders have agreed a response to the UK's request for a Brexit delay - offering a 'flexible' extension depending on how events unfold in Westminster.
The European Council considered what to do over a working dinner this evening, with talks continuing well into the night.
At around 11:20pm Brussels time, Council President Donald Tusk confirmed the EU27 had reached an agreement.
He added he was meeting with Theresa May to discuss the European leaders' proposals.
Mr Tusk also revealed details of the plan being put forward by the Council, and confirmed that Mrs May had agreed to it.
EU27 responds to UK requests in a positive spirit and:
👉 agrees to Art. 50 extension until 22 May if Withdrawal Agreement approved next week
👉 if not agreed next week then extension until 12 April
👉 approves ‘Strasbourg Agreement’
👉 continues no-deal preparations
— Charles Michel (@eucopresident) March 21, 2019
Under the proposals, a third meaningful vote on the withdrawal agreement will be held in Westminster next week.
If it passes, there will be an orderly Brexit on May 22nd.
If it fails, the UK government will have until April 12th to decide what to do.
They could leave with no deal at that point.
Alternatively they could decide to request a further extension - which would likely require them to contest the European elections, and would be long-term delay to Brexit.
Donald Tusk also indicated the British government could consider revoking Article 50 in that situation.
Either extension would mean a no-deal Brexit on March 29th - the existing Brexit deadline - would be avoided.
Speaking during a late night press conference after the agreement was reached, Mr Tusk said: "I think it's a good sign.
"Frankly speaking, I was really sad before our meeting - now I am much more optimistic."
EU leaders also signed off on the legally-binding assurances on the Irish backstop agreed earlier this month.
Earlier, draft conclusions from the summit of EU leaders in Brussels indicated that the bloc was willing to agree an extension until May 22nd.
The conclusions noted that any extension would be conditional on the Brexit Withdrawal Agreement passing through the House of Commons next week.
EU leaders were also reported to be considering May 7th as a possible extension date - with the UK to indicate by April 11th whether it will field candidates in the European elections.
UK Prime Minister Theresa May had requested an extension until June 30th - however, European leaders expressed concern that this would interfere with the upcoming elections.
The agreed proposals from the EU mean the looming threat of a no-deal exit on March 29th is diminished.
However, Mrs May will have to find a way to get MPs to approve the deal when she returns to London.
The deal's already been overwhelmingly rejected by MPs twice.
Speaking during a press conference after midnight in Brussels, the British Prime Minister observed: "I think what this decision tonight does is show the clear choice that is open to MPs.
"Getting the deal through next week in a meaningful vote means we can have that extension until May 22nd... leave the European Union and do it an orderly manner.
"Not getting that vote through [means] that we'd [need to] come back to the Council before April 12th with a plan for the way forward.
"That, if it involves a further extension, would mean candidates being stood in the EU parliamentary elections. I think the choice is clear for people."
Earlier, the Taoiseach Leo Varadkar said it was time to "cut the entire British establishment a little bit of slack on this." and give consideration to the extension request.
He said a 'no deal' Brexit " can only ever be a British choice."
"Let's not forget that the March 29th deadline was set by the UK in the first place and it is always up to them even at the last moment to revoke Article 50 unilaterally.
"They do not need permission to do that so no deal, if it happens, will be a British choice and a British decision."
France President Emmanuel Macron warned that if the UK Parliament rejects the deal again, the UK will be heading "directly" for a no deal scenario.
"I am not here to comment on any other political system, I am just here to say that we do respect the vote of the British people," he said. "We do respect what the Prime Minister and the Parliament are [doing]."
"But we have to be clear. We can discuss and agree on an extension, if this is a technical extension in case of a yes vote on the agreement we negotiated over two years.
"In the case of a no vote, directly, it will guide everybody to a no deal, for sure."
He was speaking as over one million people signed a petition calling on the UK to revoke Article 50 and cancel Brexit.
Mrs May was prevented from holding a third meaningful vote on the withdrawal agreement this week after the House of Commons Speaker John Bercow said she could not ask Parliament to vote again without "substantial changes" to what is on offer.
Mrs May will be hoping that today's extension, alongside EU ratification of the legally binding reassurances on the backstop she agreed with the Mr Juncker in Strasbourg, will be enough to allow her to hold the vote.
She has also pledged to bring forward changes to domestic UK law that confirm her "previous commitments to protect our internal market, given the concerns expressed about the backstop."