David Cameron revealed his advice to his successor Theresa May in one of his last acts as Prime Minister.

The former Tory leader told MPs, including Mrs May, that he would caution her to “try to be as close to the European Union as we can be".

It was one of the few times that he mentioned the EU.

The Prime Minister who accidentally crashed the UK out of Europe tried to ensure that his legacy would be remembered for something other than Brexit.

but there had been little time to prepare what returned out to be his final day in office.

At the start of the week Mr Cameron did not expect yesterday's Prime Minister’s Questions (PMQs) to be his last.

But the dramatic withdrawal of Andrea Leadsom from the Conservative leadership race turbo-charged his ejection from Downing Street.

By the end of Monday it had become apparent that the UK had a new Prime Minister and that pressure was now on the old one to leave his post.

Mr Cameron had been expected this summer to be a sort of farewell tour to the UK and his premiership.

Pencilled in the diary already was a swansong at the G20 in September, where the US President Barack Obama would also be making one of his last global appearances.

In the end his team were left to scrabble together a plan for his final day in office with just 36 hours notice.

At PMQs he told MPs that he would be returning to the backbenches from where he would be “cheering” them all on.

He also announced help for those with contaminated blood.

And, like Tony Blair before him, he received a standing ovation from many MPs, mostly on his own benches, as he left the Commons for the last time as Prime Minister.

Hours later he was standing outside No 10 flanked by his wife and his three children.

There he said that the “greatest honour” of his life had been to act as Prime Minister for the last six years.

As he and his family left Downing Street for the last time, he said “my only wish is continued success for this great country that I love so very much”.

Standing beside their father his three children, two daughters Nancy and Florence and son Elwen, looked at times tearful.

Speaking from notes Mr Cameron, who becomes the youngest prime minister to leave office for more than a century, tried to point to his achievements in office.

He pointed to the new National Living Wage, changes to the care system, reforms to schools in England and the National Citizen Service, which has seen 200,000 young people pass through its doors.

He also mentioned gay marriage, a policy first promoted by his coalition colleagues the Liberal Democrats.

In a controversial passage, in the wake of austerity cuts and just days before next week's Trident vote, he said his government had strengthened the UK's defences "with submarines, destroyers and frigates, and soon, aircraft carriers rolling out of our shipyards to keep our country safe in a dangerous world".

He praised his team, his children and his wife Samantha, who he called "the love of my life".

"You have kept me vaguely sane and as well as being an amazing wife, mother and businesswoman, you have done something every week in that building behind me to celebrate the best of voluntary service in our country", he said.

And he paid tribute to his successor saying that he was "delighted" that for only the second time in British history the new Prime Minister will be a woman.

As he left the lectern, staff and aides who had lined the street outside Number 11 cheered and applauded.

Crowds of people who had gathered outside the gated entrance to Downing Street were moved by police to allow the Camerons' car to make its final journey to offer his resignation to the Queen.

After a meeting lasting around half an hour he departed by a back door, out of the high-profile role of Prime Minister and into the history books.

Not since the Earl of Rosebery has a Prime Minister left No 10 before reaching half a century in age.

Mr Cameron will turn on 50 on October 9.