Theresa May left 10 Downing Street for the last time as prime minister with a warning to her successor that he must deliver an “exit from the European Union in a way that works for the whole United Kingdom”.

Ms May’s emotional departure speech before the famous black door of No 10 was briefly interrupted by a shout of “Stop Brexit” from a heckler outside the iron gates.

She paused only briefly before saying: “I think the answer to that is ‘I think not.’”

The outgoing PM was flanked by husband Philip who joined her on her final journey to Buckingham Palace to tender her resignation to the Queen, a little over three years after her appointment.

After a private audience with Her Majesty lasting around half an hour, the pair left for their home in Ms May’s Berkshire seat of Maidenhead, where she stays on as constituency MP.

Mr May had watched from the public gallery of the House of Commons as his wife received a standing ovation from MPs after her final session of prime minister’s questions, before the pair ate lunch together in the sun-drenched garden of No 10.

Liberal Democrats including new leader Jo Swinson joined Tories and the DUP in rising to their feet to applaud the PM after a marathon session of questions lasting more than an hour.

But Labour MPs remained firmly in their seats, and while a few clapped quietly, leader Jeremy Corbyn did not.

Theresa May made an emotional resignation speech outside No 10 (AP)

In the hour before her resignation, Ms May received a stream of resignations from ministers including her effective deputy David Lidington, chancellor Philip Hammond, justice secretary David Gauke and international development secretary Rory Stewart, who all made clear they were unwilling to serve under a PM who would not rule out a no-deal Brexit.

Speaking outside the door to No 10, Ms May confirmed that she would advise the monarch to invite Boris Johnson – who yesterday won the contest to succeed her as Conservative leader – to form a new government.

“I wish him and the government he will lead every good fortune in the months and years ahead,” she said.

“Their successes will be our country’s successes, and I hope that they will be many.”

Speaking as the UK’s second female PM, she said: “I hope that every young girl who has seen a woman prime minister now knows for sure that there are no limits to what they can achieve.”

Ms May said Mr Johnson’s immediate priority should be “to complete our exit from the European Union in a way that works for the whole United Kingdom”.

And she added: “With success in that task can come a new beginning for our country – a national renewal that can move us beyond the current impasse into the bright future the British people deserve.”

In a final caution to Mr Johnson not to squander the £27bn fiscal headroom he has built up to cope with the impact of a possible no-deal Brexit, Mr Hammond used his resignation letter to say he hoped that Ms May’s successor would use the financial position he inherits “wisely”.

And the pro-EU Mr Lidington said he was “relishing the prospect of speaking and campaigning freely for the things that matter to me and to my constituents”.

Mr Gauke said he shared Ms May’s frustration that parliament had not passed her EU withdrawal agreement, which he described as “the only deal on the table”.

“I also believe your decision not to try to defy parliament by leaving the EU without a deal on 29 March will be judged by history as the correct one,” he said.

The outgoing justice secretary said that leaving with a deal was “the only responsible way to honour the 2016 referendum result”, adding: “Without such a deal, I fear for the prosperity, security and unity of the United Kingdom.

“Given Boris’s stated policy of leaving the EU by 31 October at all costs, I am not willing to serve in his government. I believe I can most effectively make the case against a no-deal Brexit from the backbenches.”

Mr Gauke appeared to indicate that he believes the Conservative shift to the right will not last forever, suggesting that figures like himself and Mr Stewart may eventually return to cabinet.

Using the popular FaceApp software to depict the pair aged by several decades, he used the hashtag #BRB – be right back – as he wrote on Twitter: “A few ministers leaving government today. Some of us hope to return... one day.”

Mr Stewart replied: “Looking forward to that great 2045 cabinet return…”

Ms May’s departure from No 10 came after she was given a standing ovation by MPs following her final session of prime minister’s questions in the Commons.

The rancorous relationship of May and Corbyn over the despatch box continued to the final moments of their last PMQs.

Though the Labour leader paid tribute to the outgoing PM’s “sense of public duty”, he said she should feel regret for the increases in poverty, violent crime and NHS waiting times under her watch.

Theresa May receives a standing ovation as she leaves parliament

Ms May accused Corbyn of spreading “fake news” and told him: “As a party leader who has accepted when her time is up, perhaps the time is now for him to do the same.”

Mr Corbyn lashed out at Boris Johnson, claiming he had “no mandate” to govern and should call an immediate general election.

He urged Ms May to join chancellor Philip Hammond – who quit the government moments after PMQs came to an end – in “helping me to oppose the reckless plans of her successor”.

In return, Ms May grimaced and ostentatiously shook her head.