Theresa May and Andrea Leadsom will battle it out to become the next leader of the Conservative Party after Michael Gove was eliminated from the contest.
After the second MPs’ ballot, Home Secretary Mrs May finished with 199 votes, Energy Minister Mrs Leadsom 84 and Mr Gove, the justice secretary, 46.
Conservative members will now decide the winning candidate, with the result due on 9 September.
The winner will become the UK’s second female prime minister.
Mr Cameron resigned after finishing on the losing side in the UK’s EU referendum, in which there was a vote for the UK to leave.
The results were announced at Westminster by Conservative MP Graham Brady, the chairman of the backbench 1922 Committee.
There had originally been five contenders to succeed Mr Cameron, with MPs voting in two rounds to get that number down to two.
The contest now moves to its final stage with the Conservative Party’s 150,000-strong membership deciding between Mrs May, a Remain campaigner with a long track record in government, and Mrs Leadsom, a leading light of the Brexit campaign who has stressed her City and business background.
Speaking after the results were announced, Mrs May said she had secured support from all wings of the Conservative Party and pledged to bring the Tories together.
She promised “strong, proven leadership” to negotiate the UK’s departure from the EU, and to “make Britain a country that works not for a privileged few but for every one of us”.
Conservative MP Tim Loughton, Mrs Leadsom’s campaign manager, said she would bring a “huge and fresh skills base” to Downing Street if elected.
He played down her lack of cabinet experience, saying she would have “no problem stepping up to the job” having had a long career outside politics, adding: “She has done things outside of this place on so many different levels.”
Analysis by Nick Robinson, Radio 4’s Today presenter
Now we know. The name of Britain’s next prime minister will be either Andrea or Theresa.
Two women. Two Tories. Two potential leaders who – whether they like it or not, whether the country likes it or not – are destined to be dubbed the new Maggie.
That though is where the similarities between May and Leadsom end. One – of course – made the case, ever so quietly, for Remain. The other argued, ever so passionately, for Leave.
One is highly experienced – the longest-serving home secretary for more than a century. The other would be the least experienced prime minister this country has had since Pitt the Younger.
Not only has Andrea Leadsom had no Cabinet experience. Unlike David Cameron or Tony Blair, she has not served an apprenticeship as leader of the opposition.
But this run-off is about much more than that. May and Leadsom are figureheads for two very different visions of Conservatism, backed by different factions which have been at war in the party for a quarter of a century.
Mr Gove said he was “naturally disappointed” not to have made it to the final two, describing the remaining contenders as “formidable politicians”.
He welcomed the fact that the UK would be getting a second female prime minister – after Margaret Thatcher – and called for a “civilised, inclusive, positive and optimistic debate”.
Mr Gove did not announce backing for either candidate, but several of his key backers, including Education Secretary Nicky Morgan and Culture Minister Ed Vaizey, switched their support to Mrs May.
Anyone wanting to vote has to have been a member of the Conservative Party by 9 June.
Polling expert Professor John Curtice, of Strathclyde University, said the electorate for the contest represented a “very distinctive slice of Britain”.
They would be mostly over 50, disproportionately male, and “overwhelmingly middle class”, he said.
He predicted the Brexit debate would “play a role” in the contest, but not a defining one. About two thirds of Tory members voted to leave, but a higher proportion saw a candidate’s leadership credentials and vision for Britain as the most important factor, he added.
Mrs Leadsom’s departmental boss, Energy Secretary Amber Rudd, is backing Mrs May and took aim at her junior ministerial colleague’s lack of government experience.
She said: “The fact that she hasn’t had experience at the Cabinet table, hasn’t had much experience even as a junior minister – let’s face it she’s had just two years – I do think is a problem at this stage.”
But one of Mrs Leadsom’s high-profile backers, former worker and pensions secretary Iain Duncan Smith, said she would “develop” over the coming weeks and get “better and better and better”.
Mrs Leadsom is also supported by former London mayor and one-time leadership favourite Boris Johnson, who said she would replace the “absurd gloom in some quarters with a positive confident and optimistic approach”.
UKIP leader Nigel Farage said on Twitter he was backing her.