The topsy-turvy politics of Britain’s endlessly unpredictable summer took another stunning twist on Monday, with the selection by default of a prime minister who had advocated staying in the European Union but will now come under immediate pressure to fulfill her promise to lead the nation’s exit.

Theresa May, the hard-charging home affairs secretary, was elevated to Britain’s top job when the woman who was to spend the summer campaigning against her, Energy Minister Andrea Leadsom, preemptively dropped out of the contest to succeed outgoing leader David Cameron.

With only one candidate left in the race, the 59-year-old May was named the winner by acclaim, a decision met with table-thumping approval by her fellow Tories in Parliament. She will take the keys to 10 Downing Street on Wednesday, once Cameron has had a final turn in the weekly political combat session known as Prime Minister’s Questions.

By coalescing around May, her Conservative Party avoided what could have been a bruising months-long campaign that threatened to inflame the still-raw wounds of last month’s E.U. referendum.

But the move is also likely to accelerate the pressure on Britain to exit the E.U. European leaders have said Britain must act as quickly as possible to get out, as have Leadsom and other British advocates for a geopolitics-rattling divorce known as Brexit.

On Wednesday, Theresa May will become Britain’s next prime minister. She'll become the second female British prime minister after Margaret Thatcher. Here's what you need to know her in 60 seconds. (Karla Adam,Jason Aldag/The Washington Post)

May campaigned — if only barely — for the country to stay inside the E.U. But after the “leave” campaign won last month’s referendum and forced the pro-“remain” Cameron from office, May pivoted and said she would back an exit — a stance she reiterated in her victory speech.

“Brexit means Brexit, and we are going to make a success of it,” she said Monday afternoon as she stood in front of the gothic towers of Westminster and flashed a smile that is seldom seen on a politician known for her no-nonsense demeanor.

[As Britain looks to new leader, a jolt of pressure to speed Brexit]

May will become the country’s 76th prime minister, but only the second woman to hold the job following Margaret Thatcher, who stepped down over a quarter-century ago.

Although May has been occasionally likened to Thatcher — Britain’s Iron Lady — she has lately been compared to a more contemporary leader: German Chancellor Angela Merkel.

Both May and Merkel were born in the 1950s, the daughters of church pastors. They both inhabit the center-right of European politics but are also known for a strong pragmatic streak.

Both are also considered tough negotiators — skills they’ll be putting to use against one another as May seeks a divorce deal with her soon-to-be-former E.U. counterparts.

The key question now is when she triggers the start of those talks. She had earlier said she did not want to invoke Article 50 — the never-before-used mechanism for exiting the E.U. — until at least 2017.

Her reluctance to move faster has sparked speculation that she might try to find a way to avoid Brexit — a possibility she emphatically rejected Monday, saying that there would be “no attempts to remain inside the E.U., no attempts to rejoin it by the back door, and no second referendum.”

Monday’s events make it less likely that she can go back on that pledge, even if she wants to. In dropping out of the race, Leadsom emphasized that she was trying to clear a path for her erstwhile rival to get on with the business of Brexit.

The two were supposed to campaign through the summer for the affection of the Conservative Party’s 150,000 members, with the winner due to be announced Sept. 9.

[Meet Theresa May on her way to 10 Downing Street]

But Leadsom, a relative unknown whose campaign got off to a rocky start after she touted her motherhood as an advantage in a matchup with the childless May, said Monday that she had concluded that “a nine-week leadership campaign at such a critical moment for our country is highly undesirable.”

“Business needs certainty,” she said as she stood in front of a dark-brick townhouse in central London.

Just last week, Leadsom had earned the right to square off against May in the summer contest by placing second — far behind May — among Conservative members of Parliament. May was considered a strong favorite to win, but Leadsom had vowed to wage a tough campaign.

Her decision to drop out came as yet another shock in a country where such remarkable turnabouts have become a regular feature of politics.

Since voting last month to leave the E.U. — the biggest stunner of all — Britain has watched mouth agape as politicians have double-crossed each other, scores have been settled and May has emerged from near the back of the pack of prime ministerial candidates to be the only woman left standing.

By dropping out, Leadsom triggered a cascade of fast-moving developments.

First, May’s former rivals lined up behind her.

Michael Gove, the justice secretary who finished third in last week’s winnowing of candidates, quickly endorsed May on Monday. So did Boris Johnson, the former London mayor and a one-time Leadsom backer.

Hours later, Cameron walked out the front door of 10 Downing Street for one of the last times, and announced to reporters that he would yield to May by Wednesday.

“I’m delighted that Theresa May will be the next prime minister. She is strong, she is competent, she is more than able to provide the leadership that our country is going to need in the years ahead, and she will have my full support,” Cameron said.

Cameron said he would chair his last cabinet meeting Tuesday and would attend Prime Minister’s Questions in the House of Commons on Wednesday for a final time as the nation’s leader, six years after he took the job.

“After that, I expect to go to the palace and offer my resignation, so we will have a new prime minister in that building behind me by Wednesday evening,” he said.

On his way back to Downing Street, the still-mic’d-up Cameron hummed a happy tune.

A little over an hour later, in brief remarks beside cheering Conservative lawmakers outside Parliament, May promised to “steer us through what will be difficult and uncertain political and economic times.”

May, who had raced back to London after a campaign event in Birmingham, appeared to have been caught off guard by Leadsom’s withdrawal — as was nearly everyone in British politics.

[The rise of Theresa May highlights Brexit’s greatest irony]

May will take office under the mandate that the Conservative Party gained in last year’s general election, having won a narrow majority in Parliament.

But the abrupt end of the leadership contest deprives her of the explicit endorsement she was expected to receive from the party’s rank-and-file members. May had earlier said she believed that it was important that the party have a choice in its new leader and that she not take power through “a coronation.”

Opposition parties quickly seized on the fact that voters hadn’t had the chance to pick May. The veteran politician is considered to the right of Cameron, having taken a hard line on issues such as immigration and government surveillance.

“Tories now have no mandate,” tweeted Tim Farron, leader of the centrist Liberal Democrats, in a call for new elections. “Britain deserves better than this.”

Politicians from the center-left Labour Party joined Farron’s call. But they did so as Labour continued its weeks-long implosion. Angela Eagle, a former top deputy of party leader Jeremy Corbyn, announced Monday that she would challenge Corbyn for his job.

Dissidents within Labour, including Eagle, say Corbyn is ill-equipped to lead the party in a general election if the Conservatives decide to call one to renew their mandate.

May has said there will be no new vote. But in a season of constant surprise, British political observers say not to rule it out.

Karla Adam in London and Brian Murphy in Washington contributed to this report.