"I have done everything I can to convince MPs to back that deal," she said. (AFP)

Highlights "Will always regret not being able to deliver Brexit": Theresa May

Leaving office with "enormous gratitude", she said in a shaky voice

She will however stay on as PM till her party selects a new leader

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

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

Speaking at the lectern in front of the official residence at 10 Downing Street, May said she had "done my best" to make a success of Brexit but had failed to sway members of Parliament to back her deal. She told Britons that compromise was not a dirty word.

"I have done everything I can to convince MPs to back that deal. Sadly I have not been able to do so. I tried three times. 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."

And at the end of her brief remarks, May noted that she was the 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 E.U., 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 Friday morning meeting with Graham Brady, chair of the Conservative Party's powerful backbench "1922 Committee."

She will step down as party leader on June 7, following a state visit by President Donald Trump and D-Day commemorations. She will then 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 chose someone who at least pays lip-service to the prospect of a no-deal Brexit - leaving the E.U. 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.

Johnson is popular with the Conservative grassroots, 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.

A few others have already declared they want the top job, including International Development Secretary Rory Stewart and former work and pensions secretary Esther McVey. Andrea Leadsom, who resigned as House of Commons leader this week, was a finalist alongside May in 2016 and has said she is "actively considering" another leadership bid.

A raft of others are expected to follow. Among the possible contenders: May's de facto deputy David Lidington, former Brexit secretary Dominic Raab, Environment Secretary Michael Gove and Foreign Secretary Jeremy Hunt.

Under the Conservative Party rules, any lawmaker can put their name forward. Conservative lawmakers then vote in a series of rounds, removing the person with the fewest votes, until there are only two left. The Conservative Party members then select their preferred candidate.

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 deal with the E.U., 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.

But some analysts argue that she got the sequencing of Brexit terribly wrong: She launched into negotiations with the E.U. before achieving consensus within her party. She told hard Brexiteers at the start of her premiership that she'd 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?"

May's support took a nosedive 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 Labour leader Jeremy Corbyn to help break the Brexit impasse. Those talks collapsed last week. Corbyn said he couldn't negotiate with a leader on her way out.