Issuing a statement outside 10 Downing Street at lunchtime, he said that he would step down when the new leader was in place.
He said the timescale for electing the new leader who in turn becomes the next prime minister would be announced next week.
Mr Johnson said it was "painful not to be able to see through so many projects and ideas" and blamed the "herd instinct" in Westminster for his exit.
He added: "I want you to know how sad I am to be giving up the best job in the world, but them's the breaks."
Resignations by senior Tories, including Chancellor Rishi Sunak and Health Secretary Sajid Javid on Tuesday, made the PM’s position appear untenable but he appeared to be holding on until today’s announcement.
There have been calls, including from former Conservative prime minister John Major, for him to go now.
Reacting to the statement, Councillor James Kerr, the leader of the Conservative group on Falkirk Council, said: “The prime minister was correct to resign. Over the past few months, it has become increasingly clear that we need fresh leadership to unite our country.
"Whilst the resignation of a prime minister is a momentous occasion for a country, it doesn't change the job of the Falkirk Conservative group.
“It was only two months ago that we were elected on a platform to serve the people of Falkirk, and to stand up and deliver on local issues. This we will continue to do.
“We're just hard working people trying to do the best for the people of Falkirk.”
Falkirk Herald readers were also quick to voice their opinions.
Sandra Macleod said: “He could have been a good prime minister. When he acts the part he is good at it. Under normal circumstances we wouldn’t have been told all the stuff we have heard but his own party used him to win the election and then did everything in their power to get him out by leaking all this stuff to the press. Problem is now we have nobody suitable to do the job. You might be sorry what you wished for.”
Lynne Galbraith commented: “And so should the rest that knew what he was like and still supported him until it became public.”
Robert Miller snr said: “The big knives came out – the Tories are ruthless. All was not bad with Johnson, he did some honourable things ie honouring the democratic vote of Brexit which politicians did not want. Furlough another great thing and acquiring sufficient vaccine but all this over shadowed by utter stupidity on his own part. But sadly for the UK when you look at our options we are bereft of statesmen which right now we are in dire need of.”
Max Roatti said: “One less incapable. Unfortunately, he has already done the damage.”
And finally, Margaret Dodds said: “Should have happened a long time ago.”