This post mentions abortion and miscarriage and might be triggering for some readers.
After more than 50 ministers quit, Boris said it was clear his party wanted someone else in charge but that his forced departure was "eccentric".
"Today I have appointed a cabinet to serve, as I will, until a new leader is in place," he said outside his Downing Street office.
"I know that there will be many people who are relieved and perhaps quite a few who will also be disappointed. And I want you to know how sad I am to be giving up the best job in the world. But them's the breaks," he added, making no apology for the events that forced his announcement.
The 58-year-old, whose leadership has been mired in scandals over the last few months, said he will stay on until his successor is chosen.
Watch: Boris Johnson announces his resignation as UK Prime Minister. Post continues below.
There were cheers and applause as he began his resignation speech, while boos rang out from some outside the gates of Downing Street.
His wife, Carrie Johnson, was also in attendance along with the couple's daughter, Romy.