The United Kingdom and the European Union on Thursday agreed to extend the last date for Brexit to October 31. Leaders of the 27 remaining European Union states met for over five hours in Brussels, Belgium before deciding to postpone the exit of the United Kingdom until Halloween, BBC reported.

“EU27/UK have agreed a flexible extension until 31 October,” European Council President Donald Tusk tweeted. “This means additional six months for the UK to find the best possible solution.”

Tusk, speaking to reporters after the meeting, said his “message to British friends” is that “please do not waste this time”. “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,” he said. “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.

Irish Taoiseach Leo Varadkar tweeted that Britain must now hold European Union elections in May, or leave the bloc on June 1 without a deal.

British Prime Minister Theresa May had requested the European Union to grant the United Kingdom an extension till June 30, after MPs in the House of Commons rejected the withdrawal agreement with the bloc. On Tuesday, European Union leaders had said that the UK will have to provide a clear plan to justify an extension.

March 29 was the date originally set for Brexit, but the British Parliament has repeatedly failed to decide on the terms of the exit. In March, May had offered to resign if the deal was passed, in a bid to win over rebels in her Conservative Party. If the extension had not been agreed to, Britain would have left the bloc without a deal on April 12.