LONDON — Prime Minister Theresa May of Britain surrendered to mounting pressure from her lawmakers on Friday and said she would step aside as leader, after almost three years of trying and failing to lead Britain out of the European Union.
Mrs. May said she would stand aside as leader of the Conservative Party on June 7, but remain as prime minister until a successor was chosen. Though she still has a little more time in Downing Street, the announcement puts an end to one of the most turbulent — and at times shambolic — premierships in recent British history.
Her departure is likely to set off a vicious contest to succeed her within the governing Conservative Party. In truth, Mrs. May’s rivals have been jockeying for position for months as her authority ebbed and lawmakers, and ultimately cabinet ministers, mutinied.
Speaking outside 10 Downing Street, Mrs. May acknowledged that she had been unable to persuade lawmakers to support her plan to pull Britain out of the European Union, despite her best efforts.
“I believe I was right to persevere, even when the odds against success seemed high,” she said. “But it is now clear to me that it is in the best interests of the country for a new prime minister to lead that effort.”
Her failure to reach a deal, she said, would remain a matter of “deep regret.” Voice cracking, she noted at the end that she was “the second female prime minister, but certainly not the last.”
Conservative lawmakers have been deeply frustrated by Mrs. May’s failure to deliver on Brexit, which became the government’s central — some would say its sole — preoccupation after the country voted to leave the union in a 2016 referendum.
The announcement comes at an awkward moment, with President Trump scheduled to arrive in Britain on June 3 for a state visit and to take part in events to mark the 75th anniversary of the D-Day landings that preceded the end of World War II.
She then gave herself a two-year legal deadline to complete withdrawal negotiations, only to have to postpone Britain’s exit twice after failing to persuade Parliament to accept the terms she had negotiated, painstakingly, with the European Union.
Her agreement proposed keeping Britain closely tied to the bloc at least until the end of 2020, then to extract it from the European Union’s main economic structures.
But it involved compromises — notably a promise to keep the customs and trade regulations the union deemed necessary to retain an open border between Britain and Ireland until a system is available to avoid the need for checks at the frontier. That provision — which Brexit backers said defeated the whole purpose of leaving the bloc — prompted a string of pro-Brexit lawmakers to resign from her government and many in her party to vote three times against it.
Her fall followed moves to arrange a fourth vote, this time with promises that lawmakers would also be offered choices on whether to keep Britain in a customs union with Brussels and whether to hold a further referendum on the deal.
That provoked a ferocious backlash from pro-Brexit supporters within the Conservative Party and prompted the resignation from the cabinet of the runner-up in the party’s last leadership contest, Andrea Leadsom, who left her post as leader of the House of Commons.
Hard-line Brexit supporters will be determined to replace her with someone from their ranks, with the former foreign secretary, Boris Johnson; the former Brexit secretary, Dominic Raab; and Ms. Leadsom, seen as likely contenders.
But less ideological figures are likely to put themselves forward, too, including Jeremy Hunt, the foreign secretary, and Sajid Javid, the home secretary.
In March Mrs. May had already promised to step aside if Conservative lawmakers agreed to support her withdrawal plan. Then last week she accepted that she would also have to go if she failed to win support for her deal next month, when she planned to hold a fourth vote.
She has endured predictions of her demise since 2017, when she unexpectedly called a general election, then conducted a poor campaign and lost the majority in Parliament that she had inherited from Mr. Cameron. The Conservatives remained in power with the support of a small Northern Ireland party.
Deep divisions in her cabinet over Brexit weakened her at home. By contrast, the European Union remained remarkably unified in its negotiating strategy, and it remains doubtful that any other British leader will get a deal any more palatable than the one Mrs. May agreed to.
Her ability to soak up political punishment and plow on regardless won her admiration, even from some of her many critics.
But the pressure on her increased after disastrous local election results this month, when the Conservatives lost more than 1,300 seats in municipalities around the country and voters vented their frustration at the Brexit infighting and deadlock.
Then, the government announced that Britain would, after all, take part in elections to the European Parliament on May 23 — another symbol of Mrs. May’s failure to achieve a withdrawal.
The Conservatives can expect even worse results in those elections, which started on Thursday, because they will face a rival that did not take part in the local elections: The Brexit Party, founded by Nigel Farage, the former leader of the United Kingdom Independence Party, who advocates a prompt and, if necessary, uncompromising and unilateral break with the union. The results of the European elections will be declared Sunday night, after voting has finished in all of the bloc’s 28 nations.
Mrs. May had hoped the European elections could be averted by agreeing to a joint Brexit plan with the opposition Labour Party, which is led by Jeremy Corbyn. Mrs. May aimed to lure Labour with the prospect that Britain could stay — at least temporarily — in a customs union with the bloc, eliminating tariffs and some border checks, as well as the promise to give lawmakers a vote on whether there should be a second referendum on any Brexit deal.
But that idea failed to produce a breakthrough with Labour, while angering rightists in her own party who hate the idea of a second referendum, and want to break free of the bloc and be able to strike independent trade deals around the world.
Though there is no shortage of candidates to replace Mrs. May, her successor is likely to confront the same problems. There appears to be no stable majority among lawmakers for any one Brexit plan, and holding a general election to change the composition of Parliament would represent a risk, given the current volatility of British politics and the anger of many Britons at their politicians.