Britain is set to get a new prime minister this week, after a tumultuous two weeks that saw David Cameron 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.

Cameron welcomed the development and said he would offer his resignation to the Queen 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."

Follows in footsteps of Thatcher

May would become Britain's second female prime minister, following Margaret Thatcher.

Cameron announced his resignation after failing to convince voters to remain in the EU in a June 23 Brexit 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.

Cameron has announced he will stand aside as prime minister after Andrea Leadsom's decision to pull out of the Conservative leadership contest. (Photo by Jack Taylor/Getty)

Energy Minister Andrea Leadsom, a Leave supporter, dropped out of 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 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 politicians narrowed the field from five contenders to Leadsom and May. Some 150,000 party members were due to choose between them in the coming weeks, with the result to be announced in September.

Andrea Leadsom said she lacked 'sufficient support' among legislators to be leader. (Neil Hall/Reuters)

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 (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."

Leadsom apologized to May

Before her announcement, Leadsom apologized to May, telling Monday's Daily Telegraph newspaper that she believed 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.

Home secretary expected to lead British Conservatives after David Cameron 3:21

Labour parliamentarian 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 members of Parliament.

Labour legislators have passed a no-confidence motion in Corbyn, and many of his top team members 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 politicians believe the staunchly socialist, resolutely uncharismatic Corbyn lacks broad appeal to voters. Eagle said he "doesn't connect enough to win an election."

Immediate pressure

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."