Boris Johnson has said it is "painful not to be able to see through so many projects and ideas" as he announced his resignation as Tory party leader.
The PM was met with cheers from family and staff as he made his resignation speech outside No 10.
He said he had tried to persuade colleagues it would be "eccentric" to change leader and blamed the "herd instinct" in Westminster for his exit.
He added he intended to stay in office until his successor is chosen.
A timetable for a leadership contest would be announced next week, he said. The winner of that contest will become the next UK prime minister.
However, Mr Johnson is facing calls to leave No 10 immediately - including from former Conservative prime minister Sir John Major.
In a letter to party bosses, Sir John said the leadership contest should be speeded up, or if not deputy PM Dominic Raab should take over as caretaker PM.
Mr Johnson's departure followed a mass revolt by ministers over his leadership, sparked by the dramatic resignation of Chancellor Rishi Sunak and Health Secretary Sajid Javid on Tuesday.
He resisted calls to quit - including from newly-appointed Chancellor Nadhim Zahawi - for 48 hours, until it became clear that he had lost the confidence of his party and could not continue.
Speaking outside Downing Street, he said he had secured an "incredible mandate" in the 2019 general election, winning "the biggest Conservative majority since 1987".
"The reason I have fought so hard in the last few days to continue to deliver that mandate in person, was not just because I wanted to do so, because I felt it was my job, my duty, my obligation to you to do what we promised in 2019."
"I regret not to have been successful in those arguments," he said, but acknowledged that the will of his party was "clear".
"In politics, no one is remotely indispensable," he said adding: "I want you to know how sad I am to be giving up the best job in the world, but them's the breaks."
Boris Johnson resignation
He said he was proud of his achievements in office, citing taking the UK out of the EU, the government's response to Covid and rolling out the vaccine programme.
He also said he had led "the West in standing up to Putin's aggression in Ukraine".
Addressing the Ukrainian people, he said: "We in the UK will continue to back your fight for freedom for as long as it takes."
President Volodymyr Zelensky praised Mr Johnson for "realising the threat of RF [Russian Federation] monster and always being at the forefront of supporting [Ukraine]."
Mr Johnson thanked his wife Carrie and their children as well as the staff of Downing Street and "you, the British people, for the immense privilege you have given me".
"I know even if things can sometimes seem dark now our future together is golden," he added.
He promised that he and his cabinet would to serve the country's interest until a new leader is chosen. He has filled vacant posts in his cabinet, which will meet later.
He still faces a challenge, however, in replacing the raft of more junior ministers across several departments who quit to force his exit.
Mr Johnson came to power in July 2019, and six months later won a massive majority in a general election.
However, he has been dogged by controversy in recent months, including a fine for breaking his own lockdown laws and his handling of sexual misconduct allegations against former Deputy Chief Whip Chris Pincher.
The PM's speech was brief. But his departure from office won't necessarily be swift.
He wanted history to know his resignation was the fault of colleagues and not himself. The "herd", as he called it, had moved quickly, despite winning the biggest majority at the 2019 general election since 1987 and attracting new voters to his party.
The subtext is that the coalition of voters - including former Labour supporters - he assembled in 2019 may break up without him to keep it together.
He referenced the bad press he received recently, but didn't spend long on any of the mistakes he may have made in office and which provoked mass resignations and a vote of no confidence.
He simply acknowledged he hadn't persuaded colleagues that he should remain in office.
He will stay on until a new leader is elected, but it is the backbench 1922 committee that will decide the timetable and some MPs want it expedited so he is not still in office until the autumn.
With new cabinet ministers in place, he does not seem in a hurry to leave. He will want a legacy that isn't obscured by the chaotic past few days.
The Conservative Party will now hold a leadership contest to find a replacement for the departing leader.
So far Attorney General Suella Braverman is the only Tory MP to declare she will stand, and Steve Baker has said he is "seriously" considering running.
They are expected to be joined by more candidates in the coming days - although deputy PM Dominic Raab has ruled himself out.
Some Conservative MPs also have expressed concern Mr Johnson would stay in office until the autumn, with one saying he had lost "the trust and authority required to continue".
Labour leader Sir Keir Starmer said Mr Johnson should step down immediately and warned that if he did not Labour would hold a vote of no confidence in the government in Parliament.
If the government lost the confidence vote, it could lead to a general election, however, in order to pass, a large number of Conservative MPs would have to support the Labour motion.