LONDON -- Britain is set to get a new prime minister within two days, after a tumultuous two weeks that saw the previous one toppled and several potential replacements felled by political intrigue.

Home Secretary Theresa May became the country's leader-in-waiting after her sole remaining rival unexpectedly withdrew, saying Britain needs stability amid the uncertainty caused by its vote to leave the European Union.

Prime Minister David Cameron welcomed the development and said he would offer his resignation to Queen Elizabeth II on Wednesday after attending a final session of Prime Minister's Questions in the House of Commons.

Standing outside 10 Downing St. Cameron said: "We will have a new prime minister in that building behind me by Wednesday evening."

May will become Britain's second female prime minister, after Margaret Thatcher.

Cameron announced his resignation after failing to convince voters to remain in the EU in a June 23 referendum. May had campaigned tepidly for Britain to remain but on Monday sought to reassure those who voted "leave" that she would respect their wishes.

Energy Minister Andrea Leadsom, a "leave" supporter, stepped down from the Conservative leadership race Monday after a weekend furor over comments in which she appeared to say being a mother gave her an advantage over May, who has no children.

Her withdrawal -- only a week after she announced she was running -- took the country by surprise. May was 120 miles (160 kilometres) away in Birmingham formally launching her leadership campaign when Leadsom spoke outside her London campaign office.

In a brief statement, Leadsom said she had concluded she lacked "sufficient support" among legislators to be leader. She said "the interests of our country are best served by the immediate appointment of a strong and well-supported prime minister."

It is the latest spin of the political whirlwind unleashed by Britain's vote to leave the EU. Cameron's resignation announcement the next day triggered the Tory leadership race. The most prominent contenders to replace him -- including "leave" campaign leaders Boris Johnson and Michael Gove -- fell one by one amid allegations of treachery and scheming.

Conservative lawmakers narrowed the field from five contenders to two, Leadsom and May. Some 150,000 party members were due to choose between them in the coming weeks, and the result would have been announced in September.

Now, May will be invited to form a government by the queen on Wednesday. The monarch's role is ceremonial, but part of the custom of changes of government.

May, 59, is one of the most experienced ministers in Cameron's Cabinet, serving in the notoriously difficult job of home secretary, akin to the interior minister's post in other countries, for six years.

Like Cameron, she comes from the pro-EU wing of the party, but leading anti-EU Conservatives quickly rallied around her Monday. Gove, the justice secretary, said "she has my full support as our next prime minister," while former London mayor Johnson said May would "provide the authority and the leadership necessary to unite the Conservative Party and take the country forward."

At her campaign launch, May tried to reassure supporters of a British exit, or Brexit, that she would respect their decision.

She said "Brexit means Brexit" and promised that as leader she would not attempt to stay in the EU or "rejoin it by the back door."

Leadsom's decision to quit came after the weekend uproar over her comments about the role of motherhood in politics. She at first defended, then apologized for, an interview in which she said that being a mother "means you have a very real stake in the future of our country."

Before her announcement, Leadsom apologized to May, telling Monday's Daily Telegraph newspaper that she believed that having children has "no bearing on the ability to be PM."

Leadsom's rivals said both her comments on motherhood and her subsequent flip-flopping showed the junior energy minister lacked the experience under pressure required to be prime minister. Her allies accused May supporters of attempting to undermine Leadsom.

The Conservatives aren't the only ones thrown into turmoil by the referendum, which has also sparked a leadership struggle in the main opposition Labour party.

Labour lawmaker Angela Eagle on Monday launched an attempt to unseat party leader Jeremy Corbyn, a veteran left-winger who has a strong base of support among Labour members but little backing from the party's 229 lawmakers.

Labour legislators have passed a no-confidence motion in Corbyn, and many of his top team in Parliament resigned from their jobs to protest his leadership. He is refusing to resign and says he can win a leadership battle, which would be decided by a vote of party members.

Many Labour lawmakers believe the staunchly socialist, resolutely uncharismatic Corbyn lacks broad appeal to voters. Eagle said he "doesn't connect enough to win an election."

May's accession is unlikely to end Britain's political turbulence. She will be under immediate pressure to launch formal exit talks with the EU by triggering Article 50 of the bloc's constitution.

She also faces calls to seek a mandate from voters well before the next scheduled national election in 2020, although there is no legal requirement for her to do so. The opposition Labour and Liberal Democrat parties both urged her Tuesday to call a quick poll.

"It is simply inconceivable that Theresa May should be crowned prime minister without even having won an election in her own party, let alone the country," said Liberal Democrat leader Tim Farron.

Oliver Daddow, senior lecturer in politics at Nottingham Trent University, said May would be well advised to call a snap election while Labour was in disarray.

"What's in her favour is that Labour are in such a mess," he said. "She'd have to really mess it up not to win."