The UK and the EU have agreed a “flexible extension” of Brexit until 31 October.
Speaking after five hours of talks at an EU summit in Brussels, European Council president Donald Tusk said his “message to British friends” was “please do not waste this time”.
Theresa May said the UK would still aim to leave the EU as soon as possible.
Irish Taoiseach Leo Varadkar said the UK must now hold European elections in May, or leave on 1 June without a deal.
Prime Minister Mrs May had earlier told leaders she wanted to move the UK’s exit date from this Friday to 30 June, with the option of leaving earlier if her withdrawal agreement was ratified by Parliament.
Mr Tusk emerged from the talks – and a subsequent meeting with Mrs May – to address reporters at a news conference at 02:15 local time (01:15 BST).
He said: “The course of action will be entirely in the UK’s hands: they can still ratify the withdrawal agreement, in which case the extension can be terminated.”
Mr Tusk said the UK could also rethink its strategy or choose to “cancel Brexit altogether”.
He added: “Let me finish with a message to our British friends: This extension is as flexible as I expected, and a little bit shorter than I expected, but it’s still enough to find the best possible solution.
“Please do not waste this time.”
What was agreed?
A Brexit extension “only as long as necessary” and “no longer than 31 October” to allow for the ratification of the withdrawal agreement.
The UK “must hold the elections to the European Parliament” and if it fails to do this, the UK will leave on 1 June.
The European Council reiterates there can be no reopening of the withdrawal agreement negotiations
European Commission President Jean-Claude Juncker said: “There will probably be a European election in the UK – that might seem a bit odd, but rules are rules and we must respect European law and then we will see what happens.”
Mrs May then spoke to reporters at 02:45 local time (01:45 BST).
She said that although the delay extends until 31 October, the UK can leave before then if MPs pass her withdrawal deal.
“I know that there is huge frustration from many people that I had to request this extension,” she said.
“The UK should have left the EU by now and I sincerely regret the fact that I have not yet been able to persuade Parliament to approve a deal.”
She added: “I do not pretend the next few weeks will be easy, or there is a simple way to break the deadlock in Parliament. But we have a duty as politicians to find a way to fulfil the democratic decision of the referendum, deliver Brexit and move our country forward.
“Nothing is more pressing or more vital.”
The PM said that the UK “will continue to hold full membership rights and obligations [of the EU]” during the delay.