EU leaders have agreed on a plan to delay the Article 50 process, postponing Brexit beyond 29 March.
The UK will be offered a delay until 22 May, if MPs approve the withdrawal deal negotiated with the EU next week.
If they do not, the EU will back a shorter delay until 12 April, allowing the UK time to get the deal through or to “indicate a way forward”.
The UK is due to leave the EU in eight days, with or without a deal, if no extension is agreed.
- Live updates: PM appeals to EU leaders
- Your really simple guide to Brexit
- Brexit: What could happen next?
European Council President Donald Tusk tweeted that a “unanimous” agreement had been reached:
Discussions ran late into the evening on Thursday amid reports of disagreement between the 27 other EU leaders about the details.
They are understood to have discussed potential dates of 7 May or a longer delay until the end of the year.
In Brussels, Prime Minister Theresa May spoke to leaders to try to get their backing for a delay, after MPs twice rejected the withdrawal deal she has negotiated with the European Union.
BBC political editor Laura Kuenssberg said EU leaders were taking ages to agree on whether to give Theresa May a short extension to the Article 50 process, in order to try to get the withdrawal deal through the Commons, and whether to allow a potential long extension, if the deal is defeated again.
Prime Minister Theresa May spoke to EU leaders in Brussels to try to get their backing for a delay until 30 June, after MPs twice rejected the withdrawal deal she has negotiated with the European Union.
She has told European Council President Donald Tusk that she needs more time to get her deal agreed by MPs and passed into law.
The BBC’s Brussels correspondent Adam Fleming said Mrs May had spoken to EU leaders for 90 minutes and was asked several times what her contingency plans were if she lost the third “meaningful vote” on her deal in Parliament.
The BBC’s Europe editor Katya Adler said that unity among the 27 other EU leaders appeared to have started to fray when the UK prime minister was unable to give any concrete reassurances that she would be able to get the deal through next week.
She added that she had been told that a short extension until 7 May will be offered, unless by 11 April the UK says it will take part in European Parliamentary elections, in which case the delay could be until the end of the year.
French President Emmanuel Macron has warned that if MPs vote down Mrs May’s EU withdrawal agreement next week, the UK will leave without a deal.
“In the case of a negative British vote then we’d be heading to a no deal. We all know it. And it’s essential to be clear in these days and moments,” said Mr Macron as he arrived at the summit.
EU Brexit negotiator Michel Barnier said that a short Brexit delay “should be conditional on a positive vote next week in the House of Commons”.
“We have done our best, now the solution is in London,” he said.
What is the Plan B?
By Reality Check’s Chris Morris
It’s been clear that EU leaders believe a short extension of the Article 50 process is possible.
But there have been different views about how long “short” should be. And a strict interpretation of the law rules out an extension until the end of June, if the UK doesn’t take part in European elections.
That’s why the 27 EU leaders offer a possible extension until 22 May, the day before voting in the elections begins.
For now, the focus is on the condition that an extension can be offered only if UK MPs vote for the Brexit deal next week. But EU leaders know the numbers don’t look good for the government.
So, what does their Plan B look like? President Macron said that a “no” vote from MPs would guide us towards no deal.
But would he say the same thing in a week’s time, when there may have to be another emergency EU summit just before the Brexit deadline?
A longer extension – an idea rejected by Theresa May – remains a possibility. But the legal and political calculations that surround it are complex, and difficult to predict.
On her arrival in Brussels, Mrs May said she “sincerely hopes” the UK will leave the EU with a deal and she is still “working on” ensuring Parliament’s agreement.
She said that she had “personal regret” over her request to delay Brexit, but said it would allow time for MPs to make a “final choice”.
Mrs May said: “A short extension gives us that opportunity to decide to leave the European Union, to deliver on that result of that referendum and I sincerely hope that will be with a negotiated deal.”
She added: “I’m still working on ensuring that Parliament can agree a deal so that we can leave in an orderly way.”
- Revoke Article 50 petition crashes site
- John Bercow: MPs are not traitors
- Corbyn calls for Brexit compromise
Earlier, speaking in the German Parliament, Angela Merkel said the EU could meet Mrs May’s request to delay Brexit if in the next week there was a “positive vote” on the withdrawal agreement in the UK Parliament.
The German Chancellor said European elections at the end of May would have to be considered during discussions on the suggested extension deadline of 30 June, adding: “But of course we can certainly talk about a short term extension.”
Brexit: EU leaders agree Brexit delay plan}