Boris Johnson said he wouldn't be the next prime minister of the UK.
The possibility of Johnson returning to power in two months was ended by the declaration.
His departure left two Conservative Party MPs in the running to succeed Liz Truss, who resigned on Thursday after a disastrous six weeks in power.
One of the two remaining candidates is a former cabinet minister.
Sunak was second in the last leadership election, which was won byTruss.
Johnson claimed in his message that he had secured the support of enough Conservative MPs to reach the next round in the selection process, which would allow ordinary party members to choose between the two candidates with support from the most MPs.
He said there was a good chance that he would be successful in the election with Conservative Party members.
He said he didn't think he would be able to govern effectively if he returned to power. He said that he was going to quit.
The prime minister resigned in July after a string of scandals. Despite saying he followed the rules, Johnson was found guilty of attending an illegal gathering.
In June, Chris Pincher, Johnson's deputy chief whip, resigned after being accused of drunkenly groped two men. When he appointed Pincher, Johnson said he was unaware of the allegations, but they fell apart and he resigned.
Reports in the wake of Truss's resignation suggested that Johnson was interested in running.