Jeremy Hunt will go up against Boris Johnson in the final round of the Conservative leadership race after Michael Gove was knocked out in the last vote by Tory MPs.
The foreign secretary now faces runaway favourite Johnson in a ballot of Conservative party members, with the new prime minister due to be in place by the week beginning July 22.
Hunt had dropped to third place in the penultimate round of MP votes earlier on Thursday, but recovered to claim the second slot in the run-off, winning the support of 77 MPs, just two ahead of the 75 who backed Gove.
Johnson, who has led comfortably throughout, secured the votes of 160 MPs in the final round, well over half of Tory MPs. Home secretary Sajid Javid was knocked out of the race at lunchtime.
Earlier in the day, a Johnson campaign source insisted they were not attempting to gerrymander the result.
The fact that Johnson put on just three votes since the afternoon ballot raised suspicions that his campaign had "loaned" votes to Hunt to ensure he went through rather than Gove.
Johnson is the firm favourite amongst Tory members, with the latest poll by Conservative Home showing that 62% favoured him as the next leader, compared to just 11% who backed Hunt - a huge gulf between the two that Hunt will struggle to overcome.
In a tweet after the result, Hunt described himself as the "underdog" but "surprises happen".
He went on to call the race "a credit to our brilliant party", describing it as a contest between: "someone who started in care & reformed the education system, someone who took on the hard left and transformed London, the son of a bus driver who became Home Secretary and in case I forgot to mention an entrepreneur."
Johnson also responded to the result on Twitter with a message of thanks to his supporters.
Hunt also enjoys the support of big name backers from both wings of the party, including Brexiteers Liam Fox and Penny Mourdant, and Remainer Amber Rudd.
His campaign got off to a bumpy start when he appeared to flip-flop on whether he was prepared to take Britain out of the EU without a deal, and although he recovered to hold second place through most of the voting, he struggled to gain real momentum and firmly establish himself as the main challenger to Johnson.
Gove gained 10 MPs on Thursday lunchtime and appeared to have won key support from previous backers of Rory Stewart, helping catapult him into second. However, Hunt pulled ahead again in the final vote.
Gove’s hopes of making the final two suffered a serious setback after he admitted to having taken cocaine at several "social events" in the 1990s while working as a journalist, and he had come in third place behind the foreign secretary in the first three rounds of voting. He expressed his disappointment on Twitter and wished Hunt and Johnson luck.
Earlier, Johnson’s allies denied that he was planning to ‘lend’ his own MP backers to Hunt in the final round of voting to keep Gove off the ballot.
There has been speculation at Westminster that because Johnson was so far ahead of his rivals, he could encourage some of his supporters to vote for the candidate he would prefer to face in the final round.
Johnson was keen to avoid a showdown with Gove, his former Vote Leave colleague who infamously turned against him during the 2016 leadership campaign.
The lunchtime results suggested there had been no attempt to keep Gove off the ballot yet, though Johnson's vote rising by more than Javid's decreased suggests his MPs did engage in tactical voting to knock Stewart out on Wednesday.
During the race, Hunt had been billing himself to the One Nation group of Tory MPs as the “moderate” candidate who could take on Johnson, the implication being that Gove would have been more likely to allow a no-deal Brexit.
A source in the Hunt camp urged MPs to avoid the "psychodrama" of a Johnson-Gove final.
"Boris and Michael are great candidates but we have seen their personal psychodrama before: it's time to offer the country someone the EU will actually talk to," they said.