LONDON (AP) -- In a carefully orchestrated political ballet, David Cameron left his job and his home at 10 Downing Street on Wednesday, resigning as prime minister soon afterward at Buckingham Palace. Theresa May then became Britain's new leader, accepting an invitation to govern from Queen Elizabeth II.
The palace confirmed in a brief, formal statement that "the Right Honorable David Cameron MP had an Audience of The Queen this evening and tendered his resignation as Prime Minister and First Lord of the Treasury, which Her Majesty was graciously pleased to accept."
Soon afterward the palace released a photo of May curtseying to the monarch at the palace.
In the traditional change of government ceremony, Cameron met the queen at the palace and recommended that the monarch invite May -- his successor as Conservative Party leader -- to form a new government.
Cameron resigned after making a brief statement outside the prime minister's residence, his home for more than six years.
"It has been the greatest honor of my life to serve our country as prime minister over these last six years, and to serve as leader of my party for almost 11 years," he said, accompanied by his wife Samantha and his children -- 12-year-old Nancy, 10-year-old Elwen and 5-year-old Florence.
"It's not been an easy journey and of course we have not got every decision right, but I do believe that today our country is much stronger," Cameron said.
He said May would provide "strong and stable leadership" and wished her luck in negotiations for Britain leave the European Union -- the issue that caused his demise.
Earlier, Cameron made his final appearance as prime minister in Parliament, turning the usually raucous prime minister's questions session into a time for praise, thanks, gentle ribbing, cheers -- and a sprinkle of criticism.
The warmth in the House of Commons culminated in loud applause and a standing ovation from his Conservative colleagues for Cameron, 49, who resigned after voters rejected his advice and decided to leave the European Union.
"I will miss the roar of the crowd. I will miss the barbs from the opposition," Cameron said, promising to watch future exchanges as a regular Conservative lawmaker on the back benches.
He even poked fun at himself, reminding legislators of a barb he directed at then-Prime Minister Tony Blair more than a decade ago: "He was the future once."
"As I once said, I was the future once," Cameron noted, as his wife and children watched from the public gallery.
Despite the suddenness of Cameron's exit -- less than three weeks after the June 23 referendum on Britain's membership in the EU -- he appeared relaxed and confident as he absorbed both praise and carping from opposition lawmakers.
Replying to Labour leader Jeremy Corbyn, who is facing his own leadership challenge from two Labour lawmakers, Cameron poked fun at Labour's leadership turmoil, noting that the Tories had had "resignation, nomination, competition and coronation" while Labour is still working out the rules for its contest.
He found time to congratulate Wimbledon winner Andy Murray and other British players there, and rebuffed rumors that he does not like Downing St.'s resident cat, Larry -- "I do!"
Cameron noted that he had answered 5,500 parliamentary questions in his six years in office. Amid the jokes and tributes in his farewell question period, he fielded questions about eye surgery and a health scandal, along with criticism about the rise in food banks and his part in calling the vote that ended up with Brexit -- a Britain departure from the 28-nation EU.
Trying to reclaim his legacy from Brexit, Cameron said his government had cut the deficit, overseen economic growth and legalized same-sex marriage. And he offered the closest thing he has ever given to a mission statement: "I believe that politics is about public service in the national interest."
May, 59, has been Britain's Home Secretary in charge of immigration and law and order for the past six years. She has the tough task of calming the country and global financial markets after the upheaval that has followed Brexit vote.
Although May backed remaining in the EU, she has reassured "leave" supporters that "Brexit means Brexit, and we will make a success of it."
She is expected to quickly unveil a new Cabinet lineup, including a minister in charge of implementing Brexit. Observers are keen to see if she appoints former London Mayor Boris Johnson or Justice Secretary Michael Gove to new jobs. The two Conservatives headed the "leave" campaign but then turned on one another in the leadership contest.
She is under pressure -- both from pro-Brexit Conservatives and other EU leaders -- to start formal exit talks with the bloc. But Tony Travers of the London School of Economics said May would likely not rush to trigger Article 50 of the EU constitution, which starts a two-year countdown to a final exit.
"I don't detect Theresa May being an impulsive person," Travers said. "I think she's a cautious person, and the British political establishment needs to come to terms with this massive decision."
There is also speculation that May, Britain's second female prime minister after Margaret Thatcher, will boost the number of women in top posts.
Wednesday's newspapers offered mixed judgments of Cameron, a politician toppled by his decision to call a referendum on EU membership -- which he then lost.
The Daily Telegraph said in an editorial that Cameron "leaves behind a stronger country, a thriving economy and more chances to get on in life." But The Sun said Cameron had been "undone by his Olympian overconfidence," while the Guardian called him a "prime minister of broken promises."
Cameron drew praise from one old adversary, with European Commission President Jean-Claude Juncker saying he would miss the British leader.
Cameron once derided Juncker as a Brussels backroom bureaucrat and tried to block him from becoming commission president. But Juncker told reporters in Beijing that he had "no beef" with Cameron.
"I have experienced a man who is serious, who is a fan of no-nonsense policy and who was delivering at each and every moment when things started to become serious," Juncker said.
Copyright 2016 The Associated Press. All rights reserved. This material may not be published, broadcast, rewritten or redistributed.