LONDON — A political era ended Monday – unexpectedly and without an election – as Prime Minister David Cameron said he will step down in two days in favor of Home Secretary Theresa May, who will become Britain’s second female leader.

Cameron announced his resignation last month because he backed the losing side in a referendum for Britain to leave the European Union. So did May – but infighting, bad timing and cold feet among leaders of the victorious “leave” campaign means that she will have the task of leading a divided country out of the EU.

The latest chapter in the political turmoil spawned by the EU vote moved with breathtaking speed.

On Monday morning, there were two candidates to lead the governing Conservative Party. At noon, Andrea Leadsom stepped down, making May leader-in-waiting. By late afternoon, Cameron had announced that May would be moving into 10 Downing Street within 48 hours.

“We will have a new prime minister in that building behind me by Wednesday evening,” Cameron said in a brief statement outside the leader’s official London residence.

Cameron, who has governed since May 2010, said he will offer his resignation to Queen Elizabeth II at Buckingham Palace on Wednesday after attending a final session of Prime Minister’s Questions in the House of Commons. The monarch will then invite May – as leader of a party with a majority in Parliament – to lead a new government.

Speaking outside Parliament surrounded by Conservative colleagues, May said she was “honored and humbled” to have been chosen as the party’s new leader.

May campaigned tepidly to remain in the EU, but sought to reassure those who voted “leave” that she would respect their decision. She said there would be no attempt to avoid a British exit from the bloc.

“Brexit means Brexit, and we’re going to make a success of it,” she said, promising to deliver “a strong, new positive vision for the future of our country.”

May’s sudden victory came when Leadsom, the energy minister, stepped down from the Conservative leadership race 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.

Only a week after she announced she was running, 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.”

Cameron’s resignation announcement the day after the June 23 referendum triggered the Tory leadership race.