Media playback is unsupported on your device Media caption David Cameron left Downing Street for the final time with his family by his side

David Cameron said being prime minister had been "the greatest honour" of his life as he prepared to formally resign.

Flanked by his wife and children in Downing Street, he said the UK was "much stronger" than when he took over.

He then went to Buckingham Palace to tender his resignation to the Queen, who has now formally appointed Theresa May as his replacement.

Earlier Mr Cameron took PMQs for the final time, telling MPs he would "miss the roar of the crowd".

After taking office, Mrs May, the home secretary, will set about naming her own frontbench team.

Before driving to Buckingham Palace, Mr Cameron spoke outside No 10, saying he had "not got every decision right" but adding: "I do believe that today, our country is much stronger."

"Politicians like to talk about policies, but in the end it's about people's lives," he said, pointing to the government's record on employment, the NHS and defence.

He wished Mrs May well, saying she would provide "strong and stable leadership", and paid tribute to his wife Samantha and his children.

As the family left for the final time, he said his only wish was "continued success for this great country that I love so very much".

A statement from Buckingham Palace confirmed he had tendered his resignation as prime minister and the Queen was "graciously pleased" to accept.

Image copyright AP Image caption Mr Cameron addressed the world's media outside No 10

Image copyright PA Image caption He was joined by wife Samantha and their children Nancy, Florence and Arthur Elwen

Image copyright PA Image caption As they left Downing Street, Mr Cameron wished the UK "every success"

Image copyright AP Image caption Mr Cameron made the short drive to Buckingham Palace to formally resign as PM

Image copyright PA Image caption Theresa May was appointed as Mr Cameron's replacement

Media playback is unsupported on your device Media caption Tributes to David Cameron at final Prime Minister's Questions

In the Commons, Conservative MPs rose as one to applaud Mr Cameron at the end of his 182nd PMQs session as prime minister, as did former Lib Dem Deputy Prime Minister Nick Clegg. Labour MPs also joined in with the clapping, including leader Jeremy Corbyn.

Mr Cameron told his MPs that he intended to stay in public life and would be "willing them on", saying "nothing is impossible". In his final remarks, he reprised a comment he made to Tony Blair during his first PMQs as opposition leader in 2005, saying: "I was the future once."

Image copyright AFP Image caption The prime minister paid tribute to his successor, describing her as a "hard negotiator"

Image caption David Cameron's family were in the House of Commons for his last appearance - this is an aerial shot of them returning to Downing Street

Image copyright Reuters Image caption Theresa May will become the UK's second female prime minister later on Wednesday

During a generally light-hearted and jocular session of Prime Minister's Questions, Mr Cameron said he had clocked up 5,500 questions at the dispatch box, joking that he would leave it to others to decide how many he has answered.

He dismissed suggestions he will look to take over as the host of Top Gear or England manager, joking they "sound even harder" than being PM.

He also stressed his love for Larry the Downing Street cat - amid rumours that he was not a fan - a point he later emphasised on Twitter and swapped warm wishes with Jeremy Corbyn, saying he had almost come to admire the Labour leader's "tenacity" in hanging on to his job.

'Amazing moments'

Defending his economic, social and foreign affairs achievements, Mr Cameron said there had been "many amazing moments" over the past six years of "public service in the national interest".

Media playback is unsupported on your device Media caption Leaving Downing Street: How previous PMs have come and gone

Mr Cameron "warmly congratulated" Theresa May, who sat next to him during the session, on her election and told Mr Corbyn that "when it came to female prime ministers I am pleased to say pretty soon it is going be two-nil".

Mr Corbyn said that although he had often disagreed with the PM, he thanked him for his service over the last six years and praised him for his backing for equal marriage and his efforts to secure the release of Shaker Aamer from Guantanamo Bay.

The Labour leader also paid tribute to Mr Cameron's wife Samantha and his family, who watched the proceedings from the public gallery. His daughters Nancy and Florence were seen to give their father a wave and cheer him on during the session.

Earlier, Mr Cameron told the Telegraph he came into Downing Street to "lead people through difficult decisions so together we could reach better times", adding "as I leave today, I hope people will see a stronger country, a thriving economy, and more chances to get on in life."

Later, after saying goodbye to staff at Downing Street, the PM will tender his resignation to the Queen,

Royal audience

The BBC's royal correspondent Nicholas Witchell said the private audience was likely to be a short one, potentially about 20 minutes.

Soon after, Mrs May will then make her own way to Buckingham Palace, accompanied by her husband Philip, when she will be asked to accept the monarch's offer to form a new government.

Media playback is unsupported on your device Media caption Mark Easton looks back at the Cameron years

Our correspondent said Queen Elizabeth was likely to ask the new PM, who will be the 13th leader of her reign, about her "intentions and programme" for government.

Mrs May, who at 59 becomes the oldest incoming prime minister since Jim Callaghan in 1976, will then return to No 10 as the country's second female prime minister, following in the footsteps of Margaret Thatcher.

She is expected to briefly address the nation before meeting top officials, including Cabinet Secretary Sir Jeremy Heyward, and receiving a full national security and defence briefing.

She will be asked to hand-write letters to the commanders of the UK's four Trident submarines about what to do in the event of a catastrophic nuclear attack on the UK and to appoint two nuclear "deputies" - ministers who will take decisions on the deterrent if she has been rendered incapable.

Image copyright Getty Images Image caption The world's media is camped out in Downing Street as the handover of power nears

Image copyright PA Image caption The Camerons are thought likely to head to their Oxfordshire home after leaving Downing Street

Image copyright AFP Image caption While Theresa May and her husband will soon swap their Berkshire home for Downing Street

Image copyright PA Image caption Amber Rudd is among a number of female politicians expected to be promoted by Theresa May

She is also expected to take calls from a number of foreign leaders. Later on Wednesday, she will get down to the work of putting together her government - with key appointments set to be announced within hours.

The current home secretary was the only remaining candidate in the Tory leadership contest following Andrea Leadsom's withdrawal on Monday.

The contest began when Mr Cameron, who has been prime minister since 2010, announced he would step down after losing the EU referendum in June.

Removal vans were spotted outside Downing Street on Tuesday, as Mr Cameron's ministers paid tribute to him in his final cabinet meeting.

'Day job'

Former Culture Secretary Maria Miller rejected suggestions that Mr Cameron's legacy would be totally defined by the decision to leave the EU, saying that while this seemed "a very big part of the political bubble" now, other achievements would endure.

She told Sky News the prime minister has "championed gay marriage and social justice while putting the Conservative Party in the centre ground" of politics and leaving behind a "strong economic foundation" to cope with the uncertainty caused by Brexit.

The swift transition of power comes after the expected nine-week leadership campaign was truncated to just a couple of days by leading Brexit campaigner Andrea Leadsom's surprise withdrawal.

Mrs May, who backed a vote to remain in the EU, will unveil her full ministerial team over the next couple of days, with the focus on the key positions of chancellor and foreign secretary as well who will be put in charge of leading the Brexit negotiations.

She is expected to promote a number of women to senior positions, with International Development Secretary Justine Greening and Energy Secretary Amber Rudd among those likely to get upward moves.

Asked her about her prospects, Ms Rudd told reporters: "I haven't been told anything yet so I'm just going to get on with my day job".