LONDON — An emotional Theresa May announced Friday she will resign as Conservative Party leader on June 7, triggering a rapid-fire battle to replace her as Tory leader and prime minister before Britain’s scheduled departure from the EU on October 31.

After six months of failed attempts to get her Brexit divorce package ratified by parliament, the U.K. prime minister finally accepted defeat Friday, accepting a new leader is needed to resolve the U.K.’s protracted Brexit process.

The announcement draws to a close one of the most tumultuous and unsuccessful premierships in modern British history, leaving an almost unprecedented challenge for her successor, who must find a way through the impasse where she has failed.

The front-runners to replace May in No. 10 Downing Street will be under enormous pressure from grassroots Conservative Party members to take a more hard-line approach to Brexit, raising the prospect of a no-deal exit later this year despite a clear majority in parliament opposed to such an outcome.

Britain’s next prime minister faces the same daunting challenges as May, with a parliament opposed to no-deal and the terms of divorce on offer. European leaders have repeatedly warned they will not renegotiate the deal that May agreed with Brussels in November.

The leading contenders to replace her as prime minister were quick to praise her.

Downing Street insiders believe a general election is all-but inevitable, likely pitting a Conservative leader committed to a no-deal Brexit against Labour’s Jeremy Corbyn, who is under pressure to unequivocally back a second referendum on Britain’s withdrawal.

In her statement, delivered just after 10 a.m. outside No. 10, May confirmed she will stay on as prime minister until a new leader is in place, welcomingU.S. President Donald Trump to London for his state visit early next month. The process to select a new leader will begin the following week.

"I feel as certain today as I did three years ago that in a democracy, if you give people a choice you have a duty to implement what they decide,” she said, setting out why she believes it is imperative for any future leader to succeed where she had failed in taking the U.K. out of the European Union.

"I have done my best to do that,” she said. "I have done everything I can to convince MPs to back that deal. Sadly, I have not been able to do so.” She later added: "It is and will always remain a matter of deep regret to me that I have not been able to deliver Brexit."

May said it is now up to a new prime minister to find a way forward. "It will be for my successor to seek a way forward that honors the result of the referendum.”

To succeed, however, May insisted the new leader would have to compromise. “Compromise is not a dirty word,” she declared.

Close to tears

For May, this compromise had come too late when her authority as prime minister was shot, leaving the opposition Labour Party unwilling to move from their red lines.

May gave a quick run through of her achievements in office — a fall in national debt, new environmental measures and a more jobs. The reality, as she and her closest aides know, is that British government has ground to a halt under the challenge of Brexit. Her determination, set out in her first speech as prime minister in July 2016, to respond to the Brexit referendum by not only taking Britain out of the EU, but making life better for ordinary people who had voted for British withdrawal, was never realized.

Ending her speech, May’s emotions finally cracked. "I will shortly leave the job that it has been the honor of my life to hold,” she said. "The second female prime minister, but certainly not the last.” And then, with her voice shaking as she came close to crying, Britain’s prime minister concluded: "I do so with no ill will, but with enormous and enduring gratitude to have had the opportunity to serve the country I love."

The leading contenders to replace her as prime minister were quick to praise her.

Environment Secretary Michael Gove said it was “a moving speech from a Prime Minister who deserves our respect and gratitude.” The former Brexit Secretary Dominic Raab said she “showed her integrity [and] remains a dedicated public servant, patriot and loyal Conservative.”

Boris Johnson, the former foreign secretary and front-runner in the leadership race agreed that it was “a very dignified statement.”

“Thank you for your stoical service to our country and the Conservative Party. It is now time to follow her urgings: to come together and deliver Brexit," he added.

Others fired warning shots that unity was going to be hard to achieve.

May’s Chief Whip Julian Smith warned that the compromises facing all MPs on Brexit are “set in sharp relief” by the prime minister’s resignation. He said the trade-offs May had tried to deal with needed to be addressed “now” and could not be delayed.

The veteran Conservative MP Ken Clarke, appearing on the BBC before May’s resignation, said Johnson, Raab and Gove could not expect the party to unite around a no-deal Brexit. “The idea that the Tory Party will all get together behind some Nigel Farage-type leader is for the birds,” he said, referring to the leader of the Brexit Party, which is expected to have hoovered up many Conservative votes in Thursday's European election. Clarke accused MPs of treating May “abominably.”

"Now some of the leading figures hope they are going to be prime minister of this country whose main efforts have been put into stabbing Theresa May and getting rid of her," he said.

'Get Brexit done'

May becomes the fourth Tory prime minister in a row whose career has been ended by Europe — David Cameron, John Major and Margaret Thatcher before her.

European leaders were also quick to pay their respects, although there was little sign they felt any responsibility. French President Emmanuel Macron sent May "a personal message of support and thanks," said an Elysée official, adding that it is “too early to speculate on the consequences of this decision.” The priority now, said the official, is to preserve the "good functioning of the EU, which requires a speedy clarification."

Irish Prime Minister Leo Varadkar said: “I got to know Theresa May very well over the last two years. She is principled, honourable, and deeply passionate about doing her best for her country, and her party." EU politicians had come to admire "her tenacity, her courage, and her determination during what has been a difficult and challenging time," he said.

Tory MPs, however, were quick to demand the new leader renegotiate with the EU. “The new Conservative leader needs to bring the party back together and provide real leadership and direction,” former Northern Ireland Secretary Theresa Villers said in a statement. “He or she should immediately seek improved exit terms from the EU. We need to get Brexit done and move on from the divisions it has caused in the party and the country.”

Speaking to POLITICO, the former Brexit Secretary David Davis said: “I don’t think her worst enemies would accuse of her of not having a sense of duty. But she interpreted it in a way that was bound to fail.”

He said the next leader needs to be committed to no-deal in order to get a better divorce agreement with Brussels.

“If we are determined about no-deal it probably won’t happen,” he said. “If the new leader goes back with Malthouse/Brady [a plan for alternative arrangements to resolve the Northern Irish border issue] and says this is the only deal which will get through parliament we stand a very good chance."

"A lot depends on whether they are serious about no-deal. If we go at this properly and say we are going to do this properly, in my judgement the Brexit Party will step back, because this is a real, serious existential moment for the country," he said.