The United Kingdom will have to leave the European Union on June 1 should it fail to hold elections to the European Parliament, the European Council has said.

A document of the conclusions from the European Council after their special meeting to discuss Article 50 said: "The European Council underlines that the extension cannot be allowed to undermine the regular functioning of the Union and its institutions.

Read more: Theresa May granted Brexit extension

"If the UK is still a Member of the EU on 23-26 May 2019 and if it has not ratified the Withdrawal Agreement by 22 May 2019, it must hold the elections to the European Parliament in accordance with Union law.

"If the United Kingdom fails to live up to this obligation, the withdrawal will take place on 1 June 2019."

Irish Taoiseach Leo Varadkar underlined the ultimatum in a tweet following the decision.

Announcing the new flexible extension, President of the European Council Donald Tusk said: "Tonight the European Council decided to grant the United Kingdom a flexible extension of the Article 50 period until October 31.

"This means an additional six months for the UK. During this time, the course of action will be entirely in the UK's hands.

"It can still ratify the withdrawal agreement, in which case the extension will be terminated.

Read more: SNP demand second EU referendum

"It can also reconsider the whole Brexit strategy. That might lead to changes in the political declaration, but not in the withdrawal agreement.

"Until the end of this period, the UK will also have the possibility to revoke Article 50 and cancel Brexit altogether."

Mr Tusk went on: "The UK will continue its sincere cooperation as a full member state, with all its rights, and as a close friend and trusted ally in the future.

"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."

A review of progress on Brexit set for June will involve the EU "taking stock" and is "not another cliff edge", European Commission President Jean-Claude Juncker said.