Theresa May is set to enrage her critics within the Conservative party after setting herself up to stay on as prime minister until the winter while presiding over a long delay to Brexit.

She told MPs just weeks ago that she was “not prepared to delay Brexit any further than 30 June” as prime minister and said she would resign once this stage of talks was complete – prompting her rivals to gear up for a summer leadership contest.

But as EU leaders met on Wednesday night to decide on another lengthy Article 50 extension, a Conservative source said the prime minister’s promised departure was tied to passing the withdrawal agreement rather than a specific date.

After six hours of talks late into the night leaders agreed to extend the new Brexit deadline until 31 October, with a potential summit in June to review the situation.

Ms May tried to play down the consequences of the expected long extension as she arrived at the meeting on Wednesday evening, telling reporters that “what is important is that any extension enables us to leave at the point we ratify the withdrawal agreement” rather than the length.

Who could succeed Theresa May as Conservative leader? Show all 9 1 /9 Who could succeed Theresa May as Conservative leader? Who could succeed Theresa May as Conservative leader? Boris Johnson Former foreign secretary Boris Johnson has long been hopeful, he previously stood in the leadership contest that followed the Brexit vote and has at many times since been thought to be maneuvering himself towards the goal. He remains a darling of the party's right wing, particularly those in the ERG, and is the most popular choice among Tory voters but his leadership bid would be fiercely opposed by many MPs PA Who could succeed Theresa May as Conservative leader? Michael Gove Environment secretary Michael Gove is another member who has long wanted to be leader. He has lately been known for rousing his party in the commons, his recent speeches on the Brexit deal and Labour's no confidence motion have overshadowed the Prime Minister's. He has been loyal to the Prime Minister, partly to shed his reputation as a backstabber who abandoned Boris Johnson to stand against him in the 2016 leadership election Getty Who could succeed Theresa May as Conservative leader? Dominic Raab Former Brexit secretary Dominic Raab has emerged as a favourite to be the Brexiteer candidate in a contest to succeed to Ms May. He displayed a grip on detail in his role as Brexit secretary. When asked recently if he would like to become prime minister he replied "never say never" Getty Who could succeed Theresa May as Conservative leader? Rory Stewart International development secretary Rory Stewart is pitching himself as the sensible candidate, promising to rule out both a second referendum and a no-deal Brexit. He was only recently promoted to the cabinet, previously serving as prisons minister, where he caught headlines with a pledge to resign if he could not reduce levels of violence within a year PA Who could succeed Theresa May as Conservative leader? Esther McVey The former work and pensions secretary announced that she will be standing for the leadership when May leaves. McVey is the first to explicitly state that she intends to stand. She resigned from the cabinet in protest over May's Brexit deal AFP/Getty Who could succeed Theresa May as Conservative leader? Sajid Javid Home secretary Sajid Javid is said to have a plan in place for a leadership race. He made headlines over Christmas when he declared that people smuggling over the English channel was a "major incident" and more recently when he revoked the citizenship of ISIS bride Shamima Begum. Son of a bus driver, he wants the Conservatives to be seen as the party of social mobility PA Who could succeed Theresa May as Conservative leader? Jeremy Hunt Foreign secretary Jeremy Hunt was recently thought to be the favourite in the event of a leadership race as he could sell himself as the man to unite the party. Critics worry that his long stint as health secretary could return to haunt him at a general election. He has reportedly been holding meetings with Tory MPs over breakfast to promote his leadership PA Who could succeed Theresa May as Conservative leader? Andrea Leadsom Following the Prime Minister's second defeat over her Brexit deal, Leader of the house Andrea Leadsom hosted a dinner party at which "leadership was the only topic of conversation", The Times heard. Leadsom ran against Theresa May in the 2016 leadership election before dropping out, allowing May to become Prime Minister AFP/Getty Who could succeed Theresa May as Conservative leader? Priti Patel Former international development secretary Priti Patel is thought to be positioning herself as a contender. One MP told The Independent "she knows she's from the right of the party, the part which is going to choose the next leader, so she's reminding everyone she's there." Patel left the government late in 2017 after it emerged that she had held undisclosed meetings with Israeli officials PA

Asked whether the 30 June date was still a red line for the prime minister, the Tory source said: “She understands that the Conservative Party feels a sense that new leadership is required for the second phase of negotiations. That was the commitment she gave to her parliamentary colleagues and that’s one she stands by.”

Speaking at a 2.30am press conference after talks closed, the PM again blamed her own MPs for the delay, telling reporters: "Over the last three months I have voted three times to leave the European Union. If sufficient members of parliament had voted with me in January we would already be out of the European Union."

Back in London Ms May’s detractors were already setting themselves up for a fight, with former Tory leader Iain Duncan Smith warning that the PM must be forced out of the job if she returns with a long extension.

“I hate to say this but the reality is if we end up going and accepting a year-long, or even a nine-month extension, I think we’re going to have egg all over our face,” he told Channel 4 News at the same time as the PM addressed EU leaders over the channel in Brussels.

“It’s time for us to bite the bullet and say, look, we can’t do this any longer, we have to make a change.

“The whole thing is an utter car crash and I think what has to be established now is I think the cabinet has to have a moment with the prime minister and say this can’t go on, I’m afraid, it really can’t go on.”

But the prime minister’s allies simultaneously rallied around her. Justice secretary David Gauke said that there was no rush to change leader, and that “it may well be the last thing we need as a country is a leadership election”.

Mr Gauke told BBC Radio 5Live’s Emma Barnett programme: “If it helps the country she will walk, if it helps the country for her to stay she will stay. She will do what she thinks is the right thing for the country.”

Ahead of a late night summit in Brussels EU leaders signalled that they were looking at giving the prime minister an extension of either nine or 12 months. Donald Tusk, the European Council president, has suggested that such an extension could have a flexible end date, and terminate shortly after the withdrawal agreement is approved by the UK parliament.

After pressure from France, which argued strongly against a long extension until 2020, the Council agreed to a slightly shorter delay until October with a stock-taking exercise in June. The review at the start of the summer is expected to assess UK co-operation during and after May’s European elections.

European Council president Donald Tusk said at a 2am press conference: “Let me finish with a message to our British friends: this extension is as flexible as I expected, an a little bit shorter than I expected, but it’s still enough to find the best possible solution. Please do not waste this time.”

He added: “I think it’s always best to have a piece of something than all of nothing.”

'Please do not waste this time': Donald Tusk issues UK warning as Brexit is extended to October

The new 31 October deadline also aligns with the end of the current Commission presidency. Speaking alongside Mr Tusk, Jean-Claude Juncker joked: "I like the decision we have taken tonight because the end date has been fixed on the 31 October. I have to leave my job on 1 November. So my guess will be that we won't have an overnight session because if we have one I'll have to leave the meeting at midnight."