In a vote among Conservative Party members of parliament, Kemi Badenoch, a former equalities minister, was knocked out, leaving Sunak, Foreign Secretary Liz Truss and Penny Mordaunt, a junior trade minister, as the remaining candidates.
MPs will eliminate one more before the governing party's 200,000 members choose their new leader, who will automatically become prime minister.
Unlike in 2019, when Johnson was a clear favourite going into the contest, the result is more difficult to forecast, with polls of party members suggesting Sunak would lose to whoever is chosen to face him.
Since Johnson said he would resign earlier this month after his scandal-ridden administration lost the support of many Conservatives, the race to replace him has become increasingly ugly with the contenders trading barbs and challenging records.
Mordaunt just held on to second place and thanked colleagues for their support.
"We are so nearly across the finish line. I am raring to go and excited to put my case to members across the country and win," she said in a statement.
A spokesperson for Truss said it was "time for the party to unite behind a candidate who will govern in a Conservative way and who has shown she can deliver time and again".
Sunak, Truss and Mordaunt have presented policy offerings to add momentum to their campaigns, trying to move the focus away from pledges on tax cuts, at a time when the UK's flagging economy has left people with the tightest squeeze on their finances for decades.
Sunak, whose resignation as finance minister helped trigger Johnson's downfall, said he would implement harsher sentences for criminals who fail to attend court and would crack down on gangs that groom girls and young women for sex.
"It will be my top priority in government to keep the British public safe - and I will do whatever it takes to make that happen," he said in a statement.
All three will want to woo supporters of libertarian Badenoch, a relative unknown who has won a following for what some described as her criticism of so-called "woke" ideas.
They will also be keen to buttress their right-wing credentials to appeal to a party membership, which, according to 2020 research by Queen Mary University of London and Sussex University Party Members Project, tends to be older, male, southern English and supporters of Brexit.
They will vote in a postal ballot with the result due September 5.
A YouGov poll of Conservative members indicated Sunak would lose a run-off vote against all the others and Truss jumped to the favourite spot in the betting markets.
Truss, who has been a vocal supporter of Ukraine after Russia's invasion, repeated her commitment to increase defence spending up to 3 per cent of gross domestic product by 2030.
"We live in an increasingly dangerous world where the threat level is higher than a decade ago, and we need a stronger deterrent to face down those threats and ensure Britain leads on the global stage," she said.
"My number one priority is keeping this country safe and people can trust me to do that."
Mordaunt also committed to Johnson's so-called levelling up agenda, or tackling regional inequalities in the UK.
"My economic plan will boost competition and growth up and down the country, creating the jobs of the future and enabling the country to live well," she said in a statement.