LONDON — British Prime Minister Theresa May started her new job Wednesday, after she curtsied before Queen Elizabeth II, and outgoing David Cameron bid goodbye to Parliament.

May, the second female prime minister after Margaret Thatcher, who ran the government between 1979 and 1990, quickly appointed key members of her cabinet, including former London mayor Boris Johnson to the top post of foreign secretary.

Speaking outside No. 10 Downing St., the official residence, May paid homage to Cameron, saying she was following in the footsteps of "a great modern prime minister."

"David Cameron has led a one-nation government and it is in that spirit that I also plan to lead," May said. She said their Conservative Party believes in the "precious, precious bond" between England, Scotland, Wales and Northern Ireland.

She also called for unity, especially after Britain voted to leave the 28-nation European Union in the contentious June 23 referendum.

"It means we believe in a union not just between the nations of the United Kingdom but between all of our citizens — every one of us — whoever we are and wherever we’re from," May said. "As we leave the European Union, we will forge a bold new positive role for ourselves in the world, and we will make Britain a country that works not for a privileged few but for every one of us."

Before entering the building with her husband Philip, May said, "Together we will build a better Britain."

Earlier Wednesday in front of the Downing Street residence, Cameron said that serving as prime minister was "the greatest honor of my life."

Standing with his wife, Samantha, and their three children before he formally resigned, Cameron spoke of a legacy that includes legalizing same-sex marriage, investing in the National Health Service and giving aid to the poorest people and countries in the world.

Outgoing British prime minister David Cameron waves outside 10 Downing Street with (left to right) his daughter Nancy Gwen, son Arthur Elwen, daughter Florence Rose Endellion and his wife Samantha Cameron in central London on July 13, 2016 before going to Buckingham Palace to tender his resignation to Queen Elizabeth II.(Photo: Justin Tallis, AFP/Getty Images)

He thanked his children Nancy, Elwen and Florence, his wife, and all who supported him.

"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. "And as we leave for the last time, my only wish is continued success for this great country that I love so very much."

Cameron then headed to Buckingham Palace to formally give his resignation to the queen. "Her Majesty was graciously pleased to accept" the resignation, a spokesman for the queen said in a statement.

Before that, Cameron took questions from members of Parliament at the House of Commons, which ended in a standing ovation from lawmakers.

“I will miss the roar of the crowd. I will miss the barbs of the opposition,” Cameron said.

Cameron, 49, is the youngest prime minister to leave office since the Earl of Rosebery in 1895. He announced his resignation after the referendum, because he had campaigned to remain in the EU.

"This morning I had meetings with ministerial colleagues and others. Other than one meeting this afternoon with Her Majesty, the queen, the diary for the rest of my day is remarkably light," Cameron said, to laughter from lawmakers.

May, 59, was greeted with a huge cheer as she entered the House of Commons. She was elected Conservative Party leader on Monday after becoming the sole candidate for prime minister when her rival, Andrea Leadsom, pulled out of the leadership race.

Her other cabinet appointments announced Wednesday include veteran lawmaker and Euro-skeptic David Davis to lead Britain’s exit talks with the EU, a newly created post. Davis, who has clashed with May when she was home secretary over privacy and free-speech issues, has long advocated leaving the EU.

Her first announcement was naming Philip Hammond as treasury chief. Hammond, the former foreign secretary, replaces George Osborne, who held the post for six years. Osborne has resigned from the government.

Amber Rudd, Britain’s former energy secretary, will fill May's former job as home secretary. Michael Fallon will continue as secretary of state for defense. And Liam Fox was appointed minister for international trade.

Johnson's appointment as foreign secretary — one of the most high-profile positions in the British government — came as a surprise because he was widely acknowledged to misstep in the immediate aftermath of the U.K.'s vote to leave the EU. He also was considered a leading candidate to replace Cameron as prime minister but took himself out of the running.

Britain's Prime Minister Theresa May holds up the Conservative Party general election manifesto as she speaks at the launch event in Halifax in northern England on May 18, 2017.
Dan Kitwood, AFP/Getty Images

Britain's Prime Minister Theresa May speaks during a question-and-answer session during a general election campaign rally at Cross Manufacturing in Bath, England, on May 31, 2017. Leon Neal, AFP/Getty Images

British Prime Minister Theresa May speaks outside 10 Downing Street after returning from visiting Queen Elizabeth II at Buckingham Palace in London, where she asked for the dissolution of Parliament ahead of the upcoming general election on May 3, 2017. Kirsty Wigglesworth, AP

An employee changes the channels of televisions, on display in a store for sale in Liverpool, England, Jan. 17, 2017, as they show a live speech by British Prime Minister Theresa May. Paul Ellis, AFP/Getty Images

British Prime Minister Theresa May arrives for a young leaders reception at Riffa Fort while in Bahrain to attend the Gulf Cooperation Council summit in Manama, Bahrain, Dec. 6, 2016. Carl Court, Getty Images

Queen Elizabeth II welcomes Theresa May, left, at the start of an audience in Buckingham Palace, London, where she invited the former home secretary to become prime minister and form a new government on July 13, 2016. Dominic Lipinski, AP

Britain's outgoing Prime Minister David Cameron, left, speaks at the dispatch box with new leader of the Conservative Party and incoming prime minister Theresa May at the House of Commons on July 13, 2016. PRU, AFP/Getty Images

Britain's new leader of the Conservative Party Theresa May arrives at 10 Downing Street in London on July 12, 2016, as she prepares to attend Prime Minister David Cameron's last Cabinet meeting. Chris J. Ratcliffe, AFP/Getty Images

Britain's Conservative Party leader Theresa May, center, flanked by her supporters, speaks to members of the media at the Palace of Westminster in London on July 11, 2016. Daniel Leal-Olivas, AFP/Getty Images