For the first time since Margaret Thatcher stepped down in 1990, the next British prime minister will be a woman. Here is what you need to know about Andrea Leadsom and Theresa May. (Nicki DeMarco/The Washington Post)

The race to be Britain’s next prime minister was whittled to two on Thursday, with Conservative Party lawmakers ensuring that the country will have a female head of government — the nation’s first since Margaret Thatcher stepped down more than a quarter-century ago.

The contest will pit the home affairs secretary, Theresa May, against Energy Minister Andrea Leadsom in a race that features contenders who were on opposite sides of last month’s European Union referendum.

In a vote among 330 Tory members of Parliament, May was on top, with 199 votes, compared with 84 for Leadsom. A third candidate, Justice Secretary Michael Gove, was knocked out after securing 46 votes.

Gove had upended British politics last week by jumping into the race for prime minister at the last possible moment. The move forced the favorite, former London mayor Boris Johnson, from the contest even before he had entered. But Gove’s unexpected betrayal also angered many Conservative lawmakers and prompted them to search for an alternative candidate to stand against the new front-runner, May.

That turned out to be Leadsom, a relative unknown in British politics who serves as a junior minister but has never been a member of the cabinet — normally a prerequisite for holding the nation’s top job.

Leadsom begins the contest as a decided underdog against the better-known May, who dominated Thursday’s vote and an earlier round of balloting held Tuesday.

But May will need to persuade the party’s rank and file, who will take the summer to choose a winner.

She wasted no time Thursday making her case, which has focused on the notion that she is the only one who can bring together the party’s warring “remain” and “leave” factions. Leadsom draws her support principally from the leave camp.

“We need proven leadership to negotiate the best deal for leaving the European Union, to unite our party and our country,” May said just moments after the vote.

The winner will be announced Sept. 9 and will replace David Cameron. He announced his plans to step down late last month, just a day after he was unable to persuade the country to back the remain campaign in a referendum on Britain’s E.U. membership.

Either Leadsom or May will be Britain’s first female prime minister since Thatcher, who led the country from 1979 to 1990, and the second in British history.

With Hillary Clinton topping presidential polls in the United States and Chancellor Angela Merkel continuing to govern Germany, three of the West’s leading countries could all be governed by women by January — a historic first.

And in Scotland, a woman — First Minister Nicola Sturgeon — could become a chief antagonist for the new British prime minister. Scotland favored remaining in the European Union, and Sturgeon could lead Scottish efforts to seek another independence bid from the United Kingdom to stay in the E.U. fold.

It is just one front in the tricky post-referendum aftermath facing May or Leadsom.

Both candidates have vowed to follow through with a British exit from the European Union — popularly known as Brexit — by triggering Article 50 of the Lisbon Treaty, the never-before-used mechanism by which countries can leave the 28-member bloc.

But they disagree about when to move. May has suggested that it will not happen this year. Leadsom has said she will act as quickly as possible, as European leaders have demanded. “We need to get on with it,” she recently told the BBC.

Leadsom and May were on opposite sides of the E.U. debate. Leadsom, a former bank executive, emerged from relative obscurity by taking a leading role in the leave campaign.

May officially backed remain, but in practice she largely sat on the sidelines.

She has long held strongly Euroskeptic views and has said there will be no rerun of the referendum if she becomes prime minister. “Brexit means Brexit,” she said last week when she announced her candidacy.

Seeking to assuage any doubts among leave backers, she has at times even taken a harder line than her pro-Brexit rivals. This week, for instance, she refused to guarantee that E.U. citizens living in Britain will be allowed to stay once the country has left the bloc, saying the matter is up for negotiation. Other contenders, including Leadsom, took a more conciliatory line, saying that no one would be kicked out of the country because of Brexit.

Despite May’s maneuvering, Leadsom has sought to raise questions about the home secretary’s dedication to the Brexit cause. Leadsom has argued that the country can trust only a true leave champion to drive the hard bargain with Brussels on cutting ties.

May, who has been responsible for the country’s internal security as home secretary since 2010, has suggested that Leadsom lacks the experience necessary for the country’s top job. May has pointed to her own record of negotiating tough security deals with her E.U. counterparts as evidence that she is uniquely prepared for the task ahead.

Both Leadsom and May are to the political right of Cameron. May has taken a hard line on immigration, saying in a speech last year that mass arrivals threatened the country’s “cohesion.” Leadsom, meanwhile, opposed the country’s legalization of same-sex marriage — a move that Cameron championed.

Of the two, Leadsom is considered more ideological, while May is seen as relatively pragmatic.

Now that Conservative members of Parliament have picked the two finalists, it will be up to the party’s 150,000 rank-and-file members to select the leader to govern this nation of 65 million.

Because the Conservatives won an absolute majority in Parliament in last year’s general election, they do not need to go back to the public to seek a mandate for a new prime minister. Instead, party members will vote by mail through the summer.

Polls show that May is well ahead of Leadsom among Conservative members, just as she was among the party’s parliamentary delegation.

The vote will come as the Brexit aftershocks continue to reverberate, with markets reeling and the pound down to its lowest level in three decades. Mohamed El-Erian, chief economic adviser to the investment giant Allianz, told Reuters on Thursday that the currency still has a long way to fall — and could reach parity with the dollar if British politicians do not move quickly to restore stability.

Leadsom said Thursday that the pound’s plummet is not necessarily a cause for concern, noting that it will help British exporters. In a speech in central London, Leadsom said she wants to “banish the pessimists” and “spread prosperity to every corner of our country.”

The speech was billed as a major economic policy address, but she gave few details of her plans.

Leadsom stayed in the hunt for the prime minister’s post despite a flurry of scrutiny over apparent exaggerations on her résumé, which suggested that she had spent years working as a fund manager for a major investment firm. Leadsom acknowledged Thursday that she had not managed funds, but she insisted that she had held a senior management job at Invesco Perpetual.

Johnson, who backed Leadsom in a move widely perceived as revenge against Gove, issued a statement Wednesday calling her “well placed to win and replace the absurd gloom in some quarters with a positive, confident and optimistic approach.”

He also celebrated the fact that the Tories will have been responsible for both of Britain’s female prime ministers, calling the center-right party “the most progressive party in Britain.”

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