LONDON — One way or another, Britain will have its second female prime minister.

The governing Conservative Party took another step on Thursday in its process to replace Prime Minister David Cameron, winnowing the contest to two candidates: Theresa May, the home secretary, and Andrea Leadsom, the junior energy minister.

When the contest is concluded in September, one of them will become the first woman to lead Britain since Margaret Thatcher, also a Conservative, stepped down in 1990. The winner will take over as Britain grapples with how to carry through with its stunning decision last month to withdraw from the European Union, a choice that Mr. Cameron opposed and that led him to announce he would step aside once the party chose a successor.

Ms. May quietly supported remaining in the European Union but has since said that she respects the outcome of the June 23 referendum and that she will seek the best possible deal for Britain as it negotiates its withdrawal from the bloc. She dominated the first stage of the selection process, in which the field is narrowed to two candidates through voting by the 330 Conservative members of the House of Commons.

Ms. May, 59, remains the favorite, but in the next round will be judged by a different constituency: registered party members, many of whom were vociferous supporters of leaving the European Union. Conservative Party headquarters has for days been unable or unwilling to disclose how many registered voters there are, but the House of Commons Library said that the latest published figure of 149,800 stems from December 2013. Voters will mail in their ballots, with the winner, to be announced on Sept. 9, becoming party leader and prime minister without having to call a general election.