LONDON — Queen Elizabeth II has seen it all before — 12 times before, to be precise.

On Wednesday, she said goodbye to David Cameron, her 12th prime minister, and hello to Theresa May, her 13th.

While a political earthquake has shook Westminster to its core and triggered the resignations of a number of politicians, the queen has managed to do what she always does: reign above the fray.

She has been a constant in a period of remarkable flux following the surprise result three weeks ago in the European Union referendum.

And as the constitutional head of state, the queen also has an important role to play in the transfer of powers from one prime minister to another.

After his final Prime Minister’s Questions, Cameron arrived at Buckingham Palace on Wednesday afternoon and formally tendered his resignation. And then, by tradition, he told the queen that he believes May is the person who commands the confidence of the House of Commons.

In a carefully choreographed sequence of events, a car carrying May, 59, pulled up on the gravel of the forecourt of Buckingham Palace, where the queen invited her in.

It was the start of a new relationship.

The 90-year-old monarch holds weekly audiences with her prime ministers, often on Wednesday evenings at Buckingham Palace, where they discuss political affairs.

“Although The Queen is politically neutral, she is kept up-to-date with political affairs and retains the right to express her views during these meetings,” according to the royal websites.

Since the queen ascended to the throne in 1952, she has seen a number of prime ministers come and go: Winston Churchill, Anthony Eden, Harold Macmillan, Alec Douglas-Home, Harold Wilson, Edward Heath, James Callaghan, Margaret Thatcher, John Major, Tony Blair, Gordon Brown, David Cameron and now Theresa May.

And it’s likely that May won’t be her last. During the course of the queen’s reign, the average prime minister has lasted only five years. The queen is 90 and appears in excellent health. Her mother lived until she was 101.

In his book “The Diamond Queen,” journalist Andrew Marr says that while there have been rumors that the queen’s favorite was Harold Wilson and that she couldn’t stand Margaret Thatcher, it’s impossible to know for sure. And in the case of Thatcher, he writes, their relationship wasn’t as frosty as some suggested.

But nobody really knows what happens in those meetings. Apart from the corgis in the room, the meetings are entirely private, and no one has spoken publicly in any detailed way about what is discussed. That didn’t stop the playwright Peter Morgan imaging those conversations in his hit play “The Audience,” starring Helen Mirren — who also slipped on a crown in the film “The Queen” — and Kristin Scott Thomas.

Of course, Cameron accidentally gave Britons an insight into his regular conversations with the monarch when he was caught talking to the then mayor of New York Michael Bloomberg about the Scottish independence referendum.

A microphone picked up Cameron saying: "The definition of relief is being the prime minister of the United Kingdom and ringing the queen and saying 'It's all right, it's okay.' That was something. She purred down the line."

John Major, the queen’s ninth prime minister, told Sky News that prime ministers “have a constitutional responsibility to tell the queen what is happening, and the queen has a constitutional right to know that and to probe and to ask questions."

He described the queen as “shrewd,” and a human library of sorts who offers wise counsel in conversations that are “entirely two way.”

“The queen, of course, has been seeing state papers since 1952. There is no one anywhere in the world who has seen and read and absorbed so many state papers as our queen,” he said.

He said that the queen was someone with whom premiers could talk freely and be reassured that the conversation would be kept in strict confidence.

“In many ways it’s cathartic,” he said.

Read more: