The prime minister had hoped to be handed an extension of the Article 50 period until 30 June before making a statement from Brussels in the early evening.
Instead, the 27 presidents and prime ministers were locked in talks long into the night after they tore up draft proposals and produced a complicated conditional plan.
Diplomats in the room painted a disorientating picture of discussions, with proposals for shorter and longer deadlines made by different countries.
EU leaders ultimately agreed that the UK could have an unconditional extension until 12 April, and a further extension until 22 May if MPs approved the withdrawal agreement next week.
The so-called “flextension” would also give the UK the option of a longer delay if needed, but only on the condition of deciding to join in European Parliament elections before April 12.
One EU official said: “March 29th is over. As of tonight, April 12th is the new March 29th.”
Speaking after the agreement was struck, European Council president Donald Tusk said Ms May “accepts the extension scenarios”.
He added: “Frankly speaking I was really sad before our meeting – now I am much more optimistic.”
European Commission president Jean-Claude Juncker added: “This closes and completes the full package. There’s no more we can give. We’re hopeful that the agreement will be adopted by the House of Commons.”
“I hope we can all agree that we are at the moment of decision,” Theresa May said at a press conference in the early hours of the morning.
“It gives us the opportunity, MPs next week, to look at the choices that clearly face them: we can leave with a deal, in an orderly manner, have that extension until 22 May – or, if we don’t get that deal through, if we don’t get that vote through then before 12 April we have to come forward with another plan, and if that plan means a further extension it means standing in those European Parliamentary elections.”
At the start of the mammoth Brussels drafting session Theresa May took questions from EU leaders about her Brexit strategy, with diplomats privy to discussions describing her responses as unconvincing and wooden.
According to several accounts, the prime minister was unable to answer what would happen if she could not pass the vote in parliament and had no apparent plan B, spooking her fellow leaders.
After Ms May was sent out of the room, the 27 leaders discussed options for an extension that included dates in April, May, and delays until the end of the year. Both conditional and unconditional extensions were considered by EU leaders.
Discussions and drafting of the new plans spilled over into a late night dinner, with a planned meeting about China-EU relations pushed back until Friday. Planned press conferences by Theresa May, Donald Tusk and Jean-Claude Juncker were postponed until just before midnight.
Leaders ultimately agreed a text which read: “The European Council agrees to extension until 22 May, provided the withdrawal agreement is approved by the House of Commons next week. If the withdrawal agreement is not approved by the House of Commons next week, the European Council agrees to an extension until 12 April and expects UK to indicate a way forward before this date for consideration by EUCO.”
Arriving at the summit in the afternoon Theresa May said the prospect of a delay was “a matter of regret” for her. She also confirmed she would seek an extension until 30 June.
On the way into the meeting Emmanuel Macron had perhaps the starkest warning of Ms May’s European counterparts, telling reporters: “We have to be clear: we can discuss and agree an extension if it is a technical extension in the case of a ‘yes’ vote. In the case of a ‘no’ vote, it will guide everybody to a no deal, for sure.”
The French president said that a longer delay would require “a deep political change” in the UK, adding: “We cannot have a long-lasting situation where there is no visibility, no purpose, no political majority.”
Meanwhile Irish prime minister Leo Varadkar described the situation in London as “somewhat chaotic” and said a no-deal Brexit would be a decision by the UK because it had the power to revoke Article 50.
We’ll tell you what’s true. You can form your own view.
At The Independent, no one tells us what to write. That’s why, in an era of political lies and Brexit bias, more readers are turning to an independent source. Subscribe from just 15p a day for extra exclusives, events and ebooks – all with no ads.