THERESA May is to make a last-ditch drive to persuade MPs to back her EU withdrawal agreement after Brussels gave her just three weeks to devise a new Brexit plan if her deal is rejected for a third time in the Commons.

If she can secure support from MPs for the deal next week, the deadline will be extended until May 22.

However, if the agreement is knocked back again, the UK will have until April 12 to set out its next steps, with a longer extension on offer only if the UK takes part in European Parliament elections in May.

READ MORE: Brexit roundup: Petition crashes UK Government site and May in MP backlash

Leaders of the remaining 27 EU member states drew up the deal in a mammoth eight-hour meeting in Brussels, after turning down the PM's plea to postpone Brexit from March 29 to June 30.

The agreement means that no-deal Brexit is no longer a possibility on March 29, but it remains on the table if MPs have not approved the Withdrawal Agreement by April 12.

The latest setback for the PM comes as a public petition calling for Article 50 to be revoked soared past 2 million signatures.

READ MORE: Petition calling for Article 50 to be revoked soars past 2 million signatures

In a midnight press conference in Brussels, the Prime Minister insisted the "flextension" plan offered MPs a clear choice.

"We can leave with a deal in an orderly manner, have that extension until May 22, or if we don't get that deal, that vote, through then we have to come forward with another plan, and if that plan means another extension, it means standing in those European elections," she said.

"Tomorrow morning I will be returning to the UK and working hard to build support for getting the deal through."

And she left no doubt that she does not believe the UK should have to elect MEPs in the polls scheduled for May 23-26 across Europe.

"It would be wrong to ask people in the UK to participate in these elections three years after voting to leave the EU," she said.

Tory former minister Sir Oliver Letwin has tabled a Commons amendment seeking to allow MPs to take control of the order paper in a bid to try to find a way forward on EU withdrawal next week.

The amendment to Monday's Government Brexit motion calls for MPs to use parliamentary time on Wednesday March 27 to consider and vote on EU exit options.

The amendment is backed by a cross-party group of MPs including Labour's Hilary Benn and Tory former attorney general Dominic Grieve.

WATCH: MP says Theresa May makes him ‘ashamed’ to be a Tory in astonishing speech

The National: Dominic Grieve

Downing Street was unable to say which day the Government would seek to bring back the Withdrawal Agreement for a third "meaningful vote" – known in Westminster as MV3.

But sources confirmed that May will table secondary legislation to remove the date March 29 from Brexit laws.

Some in Westminster predicted that the deal meant that May's days as Prime Minister were numbered.

Leave-backing Stewart Jackson, who was David Davis's chief of staff when he was Brexit secretary, said she should "stand down immediately" if she loses next week's vote.

"Conservative members will no longer tolerate her grovelling to the EU and national humiliation," said the former Conservative MP for Peterborough. "I suspect the Whips, 1922 (Committee) and Cabinet will help the process."

And a former policy adviser to the PM, George Freeman, said that if MV3 failed, Parliament would "take control, switch to Plan B and get agreement to join Efta (the European Free Trade Association) by April 12, with or without this PM."

READ MORE: EU issues Theresa May ultimatum on Brexit extension

Setting out the terms of the Brexit extension, Tusk said: "April 12 is a key date in terms of the UK wondering whether to hold European Parliament elections.

"If it is not decided do so by then, the option of a long extension will immediately become impossible."

And he added: "What this means in practice is that until that date all options remain open."

Asked how long the "long extension" eventually on offer to the UK could be, European Commission president Jean-Claude Juncker replied: "Until the very end."

Chief Brexit negotiator Michel Barnier told reporters: "It is not a deal, it is a step in the process. We are constructive and patient."

In a 90-minute presentation to her European counterparts at the start of Thursday's summit, May was reportedly pressed on what she will do if MPs reject her deal for a third time, but she did not commit herself to a Plan B or rule out a no-deal Brexit.

She was later excluded from the meeting as the EU27 thrashed out the future of Brexit in her absence.

And she had to eat alone as they continued their discussions over dinner, with her serving of lentil terrine with langoustine followed by roast duckling sent up to her in the UK delegation room by kitchen staff.

French president Emmanuel Macron said the Brexit delay avoided a "crisis situation" next week and allowed the EU to "continue working properly."

Macron said the onus is now on Britain to take its responsibilities after the European Council "lifted uncertainties with clear rules".