Tory MPs have passed a confidence motion in the government just two weeks after dumping Boris Johnson.
MPs have supported the motion by 349 votes to 238, a majority of 111.
A defeat in the vote on Monday evening would likely have triggered a general election.
But despite the party moving to oust their leader, Conservative MPs decided not to rebel and instead opted to swing behind the administration.
Bizarrely, the motion was tabled by the government itself.
Labour’s attempt at calling a confidence motion had been blocked by ministers last week, with the government arguing it was incorrectly worded.
Johnson will leave office on September 5.
Ahead of the vote, Johnson gave a valedictory speech in the Commons – and claimed the “deep state” and Keir Starmer will try to take Britain back into the European Union after he leaves office.
For his part, Starmer accused Johnson of being a “vengeful squatter mired in scandal”.
Johnson used his opening speech to run through what he perceived to be his greatest hits in office as he batted away calls for him to resign immediately.
He spoke at length about Brexit, support for Ukraine and his handling of the Covid-19 pandemic amid furious heckling from the Opposition benches.
In a hint at what is to come, Johnson also told MPs he will have “more to say” about the events surrounding his downfall “in due course”.
The debate came after a tumultuous few months which led to Tory MPs forcing him to accept he has to step down, amid accusations of lying and rule-breaking.
Johnson denied his departure from Downing Street will be the end of Brexit, claiming some people believe Labour and the “deep state will prevail in its plot to haul us back into alignment with the EU as a prelude to our eventual return”.
He also spoke about his flight in a Typhoon fighter jet last week, before adding on the Tory leadership: “After three dynamic and exhilarating years in the cockpit, we will find a new leader and we will coalesce in loyalty around him or her.
“And the vast twin Rolls-Royce engines of our Tory message, our Conservative values, will roar on – strong public services on the left, and a dynamic free market enterprise economy on the right, each boosting the other and developing trillions of pounds of thrust.
“The reason we keep winning is we’re the only party that understands the need for both. Whatever happens in this contest we will continue to fight for the lowest possible taxes and the lightest possible regulation.”
Labour former minister Kevin Brennan earlier said it was “highly unconventional” for Johnson to put down a confidence motion in his own government, adding: “Though I suppose he is an unconventional person, since only an unconventional man would want the opportunity to speak at his own funeral.”