Updated

New British Prime Minister Theresa May named former London Mayor Boris Johnson, a prominent supporter of the U.K.'s departure from the European Union, as Foreign Secretary Wednesday as part of a Cabinet shakeup.

Johnson had hoped to become Prime Minister himself in the aftermath of the so-called "Brexit" vote, but saw his ambitions dashed amid Conservative Party plotting.

Despite his prominent diplomatic position, Johnson will not lead negotations for Britain's departure from the bloc. That job will fall to David Davis, who was appointed to a special "minister for Brexit" post.

Johnson's predecessor as Foreign Secretary, Philip Hammond was named Chancellor of the Exchequer, replacing George Osborne, a "Remain" supporter who resigned from the government.

Earlier Wednesday, May vowed that Britain will forge "a bold new positive role" in the world as she was confirmed as Britain's second-ever female leader after Margaret Thatcher.

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. May then accepted an invitation from Queen Elizabeth II to form a new government.

May stressed she would fight against social injustice and that she believes in the unity of all aspects of the United Kingdom. She promised that her government would build a country that "works for everyone."

After the remarks, May stopped and waved outside No. 10 Downing Street beside her husband, Philip.

Jean-Claude Juncker, the head of the EU's executive Commission, wished May "every success in the task ahead.

"The outcome of the United Kingdom's referendum has created a new situation which the United Kingdom and the European Union will have to address soon. I look forward to working closely with you on this and to learn about your intentions in this regard,” he wrote to May Wednesday

Martin Schulz, the European Parliament's president, wrote on Twitter: "Leadership issue settled, now I expect we work quickly to deliver certainty."

Buckingham 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.

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.

Trying to reclaim his legacy from the surprise vote, 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 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."

The Associated Press contributed to this report.