LONDON — Theresa May became the leader of Britain after the country voted in a June 2016 referendum to leave the European Union. Brexit was her No. 1 job, and she failed to deliver it.

May announced Friday that she will resign as her party’s leader on June 7 and make way for a new British prime minister this summer.

Speaking in front of the official residence at 10 Downing Street, May said she had “done my best” but was unable to sway members of Parliament to back her compromise vision of Brexit. She told Britons that compromise was not a dirty word.

“I believe it was right to persevere even when the odds against success seemed high,” she said. “It is and will always remain a matter of deep regret for me that I have not been able to deliver Brexit.”

Near the end of her brief remarks, May noted that she was Britain’s second female prime minister and promised there would be more women in the highest office. Then her voice became shaky and tears almost came as she said she was departing with “no ill will, but with enormous and enduring gratitude to have had the opportunity to serve the country I love.”

May now joins a series of Conservative prime ministers who have fallen over the question of Britain’s relationship with Europe. David Cameron, John Major and Margaret Thatcher, Britain’s only other female prime minister, were all ousted in part because they could not get their party, let alone the country, to agree on how closely tied Britain and the continent should be.

May spent two years negotiating, in secret, a Brexit withdrawal deal with the EU, only to see it rejected three times by the House of Commons, with many of her own Conservatives refusing to support her. Earlier this week, she was still vowing to push on and offered a tweaked version of her Brexit plan. It was rejected so swiftly and resoundingly by so many lawmakers, including members of her cabinet, that it became clear she would be ushered out soon.

May set out her departure plans shortly after a meeting Friday morning with Graham Brady, chairman of the Conservative Party’s powerful backbench “1922 Committee.” (Brady later in the day stepped down to consider a Party leadership run.)

She will resign as party leader following a state visit by President Trump and D-Day commemorations. She will stay on as prime minister until the Conservatives, who will remain in power, select a new leader for their party and the country.

It seems likely they will choose someone who at least pays lip service to the prospect of a no-deal Brexit – leaving the EU without a transition period and adopting a relationship governed by World Trade Organization rules. Economists have predicted that abrupt change would wreak havoc on both sides of the English Channel.

“It’s quite extraordinary given that two to three years ago, the vast majority of Conservative MPs would have regarded a no-deal Brexit as impossible or highly irresponsible,” said Rob Ford, a political scientist at the University of Manchester. “Now, it’s unlikely you’d be elected as the next prime minister without some level of commitment to that approach.”

Those eager to move to 10 Downing Street have been circling for some time.

Boris Johnson, a flamboyant politician known around the country simply as “Boris,” once said, “My chances of being PM are about as good as the chances of finding Elvis on Mars.” Yet he is the current favorite in opinions polls and betting markets to become the 77th British prime minister.

On Friday, Johnson complimented May on “a very dignified statement.” He tweeted his thanks to the outgoing prime minister for her “stoical service” and said it was “now time to follow her urgings: to come together and deliver Brexit.”

Nicola Sturgeon, leader of the Scottish National Party, retweeted Johnson, adding the comment: “What a hypocrite.”

Johnson is popular with the Conservative grass roots, who play a key role in choosing the party leader. He served two terms as mayor of London, which traditionally votes Labour, proving he also has some cross-party appeal. But he lost support in some circles after the 2016 referendum, when he put himself forward as the face of the Brexit campaign. And his record as foreign secretary under May was mixed.

Others who have declared interest in the top job include Foreign Secretary Jeremy Hunt, who confirmed his candidacy shortly after May’s announcement on Friday. Andrea Leadsom, who resigned as House of Commons leader this week and was a finalist alongside May in 2016, has said she is “actively considering” another leadership bid.

A raft more are expected to follow. Among them: former Brexit secretary Dominic Raab and Environment Secretary Michael Gove.

Under Conservative Party rules, any lawmaker can put his or her name forward, as long as they have the backing of two Conservative members of Parliament. Tory lawmakers then vote in a series of rounds, removing the person with the fewest votes, until only two are left. The 125,000 Conservative Party members then select their preferred candidate.

Ken Clarke, a senior Conservative lawmaker, said the leadership contest could be hard-fought. “We are going to have a chaotic six weeks now, as a diversion, possibly a harmful diversion from the deadlock on the European Union,” Clarke told the BBC. He also noted that in Tory leadership races, the early favorite “hasn’t won one of these for a very long time.”

Marcus Roberts, international projects director at polling firm YouGov, said that if history is kind, May will be remembered as a leader who put in a good effort and even negotiated a decent Brexit deal with the EU, but who wasn’t able to play politics.

“She may have had the right intention, and she may have even got the best thing for Britain,” he said. “But it isn’t enough if you don’t know how to count in Parliament and you don’t know how to sell in public.”

There are those who say that, for any leader, getting a Brexit deal through Parliament would have been a nearly impossible task. And the dogged May stuck it out longer than many people predicted, remaining popular even with a public that hated her Brexit approach.

In a statement, Irish Prime Minster Leo Varadkar said May was “principled, honorable and deeply passionate about doing her best for her country.”

But some analysts argue that she got the sequencing of Brexit terribly wrong: She launched into negotiations with the EU before achieving consensus within her party. She told hard Brexiteers at the start of her premiership that she would honor their red lines, only to reverse her position later on. She tried a cross-party approach near the very end of her time, not at the beginning.

“When you’re at your max power as prime minister, that’s when you can make magnificent generous offers,” Roberts said. “When you’re clinging on by your fingernails, what are the incentives to make a deal with you and help you out?”

Nigel Farage, the leader of the newly created Brexit Party, said: “It is difficult not to feel for Mrs. May, but politically she misjudged the mood of the country and her party. Two Tory leaders have now gone whose instincts were pro-EU Either the party learns that lesson or it dies.”

May’s support took a nose-dive in 2017, after she called an election she didn’t have to and lost her party’s parliamentary majority, setting up many struggles to come.

Last month, she turned to opposition Labour Party leader Jeremy Corbyn to help break the Brexit impasse. Those talks collapsed last week. Corbyn said he could not negotiate with a leader on her way out.

On Friday, Corbyn tweeted: “Theresa May is right to resign. She’s now accepted what the country’s known for months: she can’t govern, and nor can her divided and disintegrating party.”

Corbyn called for an immediate general election after a new Tory leader is in place.

At the beginning of her three years in power, May promised to build a better country and spoke movingly about tackling the “burning injustices” in British society, such as life expectancy inequality, the gender pay gap and lack of social mobility.

Damian Green, one of May’s closest political allies, told the BBC that May’s inability to focus on the domestic agenda was “at least as distressing as the failure to deliver Brexit.”

In Brussels, where EU policymakers have unhappily watched the British drama for years, May’s departure was met with a shrug.

Many there long ago gave up on her ability to deliver a deal and had been counting the days until her resignation. Nor do they expect much progress to be made on Brexit until the end of October, their new expiration date for Britain’s EU membership.

But some fear that a new British prime minister will arrive with a fresh set of unrealistic expectations about what concessions the Europeans are willing to extend to London. Most EU leaders feel they have already gone as far as they will go. Britain would have to concede some of its own red lines before any major changes to the departure deal could be made, policymakers say.

“A new Prime Minister & the likely return of cakeism, unicorns and cherry-picking,” Fabian Zuleeg, head of the European Policy Center think tank, wrote on Twitter, using three of Brussels’ favorite terms for wishful thinking from London.

French President Emmanuel Macron demanded “swift clarification” about the British government’s plans for Brexit. Macron has been eager to show Britain the door and move on. May’s resignation announcement, with its risk of months more of inaction in London, played into Macron’s concerns that the European Union could get waylaid by Britain’s domestic dramas.

“We cannot wait in indefinite uncertainty,” the presidential Elysée Palace said in a statement.

In Berlin, German Chancellor Angela Merkel took note of May’s decision “with respect” and is ready to continue to work closely with London, said spokeswoman Martina Fietz.

And in the Netherlands, Prime Minister Mark Rutte said in a tweet that “the agreement reached between the EU and the United Kingdom for an orderly Brexit remains on the table.”