Yesterday we learned the full, moving details of the late Queen’s final hours from Craig Brown’s enthralling new book on Queen Elizabeth II. Today, he reveals the remarkable behind-the-scenes story of how she made her film debut opposite James Bond, and how even her family were taken by surprise.

After the death of her mother in 2002, the Queen grew more carefree, as though relieved of the burden of parental judgment. She relaxed into her role and had more fun.

Ten years on, at the age of 86, she readily agreed to perform a version of herself – or a version of a version of herself – in a short James Bond film commissioned for the opening of the London Olympics.

Lord Janvrin, her private secretary from 1999 to 2007, doubted she would have gone ahead with the idea had her mother been alive, ‘simply because she would have felt her mother wouldn’t have approved – that it would have been a bit undignified’.

When the idea was first put to her, she leapt at it. Before her deputy private secretary, Edward Young, finished telling her what she would have to do, she interrupted him. ‘I know – and then I jump out of the helicopter?’

Queen Elizabeth II agreed to perform a version of herself - or a version of a version of herself - in a short James Bond film commissioned for the opening of the 2012 London Olympics

Queen Elizabeth II agreed to perform a version of herself – or a version of a version of herself – in a short James Bond film commissioned for the opening of the 2012 London Olympics

The short film sees the late Queen having cream tea at Buckingham Palace with Paddington Bear

The short film sees the late Queen having cream tea at Buckingham Palace with Paddington Bear

Back in 1977, the year of the Silver Jubilee, the new James Bond film, The Spy Who Loved Me, had opened with Bond escaping from a baddy by skiing off the edge of a mountain. As luck would have it, he had not forgotten to wear a parachute, which opened to reveal a Union Jack.

Working on the opening ceremony for the 2012 Olympics, the director Danny Boyle had remembered this opening sequence from 35 years before. His co-writer Frank Cottrell-Boyce thought it worth replicating. ‘Apparently, all you need to do to get people to love our flag is attach it to a national icon and drop them from a great height,’ he observed.

Boyle visited Buckingham Palace for a meeting with Edward Young and the Queen’s dresser, Angela Kelly. At this point, he was only after their advice on what a lookalike Queen might wear to greet James Bond.

But to Boyle’s surprise Kelly said she thought the Queen might prefer to play herself, and asked them to wait a few minutes. ‘I remember the look of shock on Danny’s face that I would be asking Her Majesty straight away, but there’s no point in waiting around with these things,’ remembers Kelly.

‘If she said no, that would be the end of it. I ran upstairs and luckily the Queen was free so I asked her if she would be prepared to do a surprise performance for the Olympics opening ceremony. She was very amused by the idea and agreed immediately. I asked then if she would like a speaking part. Without hesitation, Her Majesty replied, ‘Of course I must say something. After all, he is coming to rescue me.’

‘I asked whether she would like to say, ‘Good evening, James’ or ‘Good evening, Mr Bond,’ and she chose the latter, knowing the Bond films. Within minutes, I was back in Edward’s office delivering the good news to Danny.

‘I think he almost fell off his chair when I said that the Queen’s only stipulation was that she could deliver the iconic line, ‘Good evening, Mr Bond.’

On the day itself, says Boyle, the Queen ‘was a one-take wonder’. She had a keen sense of drama, and knew how to keep an audience on tenterhooks. ‘It was her idea that she should be finishing a letter before she spoke.’

Like most visitors to the Palace, he was impressed, too, by her consideration towards her staff. ‘She wanted her staff to have a day out with a movie star. Daniel came, and he’s a movie star! He’s James Bond!’ When the Queen posed beside him for a still photograph it was clearly as much for her satisfaction as for his.

‘She was very, very keen and insistent that her staff did as well. I liked that about her very much. You thought, yeah, that’s decent, looking after them like that.’

The film was premiered at the Olympic opening ceremony on July 27 2012, and viewed by the largest global audience in the history of British television. James Bond arrives at Buckingham Palace in a black taxi, runs up red-carpeted stairs and is greeted (‘Evening, sir’) by the Queen’s real-life Page of the Backstairs, Paul Whybrew, and a couple of equally authentic royal corgis.

Bond is escorted into the Queen’s study. ‘Mr Bond, Your Majesty,’ says Whybrew. The familiar figure at the desk, her back towards him, fails to look up.

In the short film, the Queen carries her own sandwich in her handbag and also taps a teaspoon to the song We Will Rock You

In the short film, the Queen carries her own sandwich in her handbag and also taps a teaspoon to the song We Will Rock You

Bond stands in silence, looking a little impatient as he waits for her to finish writing a letter. As a clock chimes, he clears his throat to alert her to his presence. The figure turns around, stands up and says, ‘Good evening, Mr Bond.’

Frank Cottrell-Boyce isolates this moment, this great reveal, as key to the film. ‘Moments like this happen incrementally. Part of their power is surprise.

‘When we are surprised our prejudices and opinions evaporate for a moment and we’re briefly open-hearted. One of the most common reactions to that moment was: ‘I never felt patriotic before.’

‘Good evening, Your Majesty,’ says Bond, or, rather, Daniel Craig playing Bond. The actor had braved car chases, bullets, knives, punch-ups, explosions, defenestrations and any number of fights to the death, but he later admitted to ‘shaking with nerves’ in her presence.

Without another word, the Queen leads Bond out of her study, along a corridor and downstairs into the Palace gardens; together, they board a helicopter.

To the tune from The Dam Busters, their helicopter swoops over the Mall, where cheering crowds are waving Union Jacks, over Trafalgar Square and the Palace of Westminster, past Parliament Square, where the statue of Winston Churchill comes to life, smiling and waving his walking stick, on past the Millennium Wheel, St Paul’s Cathedral and Tower Bridge, ending up hovering above the Olympic Stadium in East London. Bond slides open the door of the helicopter, looks down and, to live gasps from the stadium, the Queen leaps out.

As the familiar twangy James Bond theme tune plays, her parachute opens out into a Union Jack. Seconds later, the Queen – the real Queen – enters the stadium to a standing ovation.

Sebastian Coe, the 2012 London Olympics chairman, was sitting next to Prince Charles, with Princes William and Harry behind them. ‘When the sequence began, the Prince of Wales looked at me and laughed a bit nervously.

‘When he realised it really was his mother up there on the screen with James Bond, he shook his head in total amazement. And when she appeared to jump from the helicopter, the two princes behind us started shouting, ‘Go, Granny, go!’

In the final year of her life, the Queen agreed to act herself once more, this time playing stooge to a bear from Peru in a short film to mark her Platinum Jubilee.

At the age of 96, the Queen drew unanimous praise for her performance, in which she takes afternoon tea with Paddington Bear. ‘Wasn’t she good? I mean really, really good?’ reckoned Dame Judi Dench. ‘Her timing was perfect. Every look, every line was just right. It was completely on the money – none of it overstated. Just wonderful.’

Frank Cottrell-Boyce, who helped script it, was also impressed. ‘She did it brilliantly and with evident enjoyment. And it wasn’t easy.

‘Paddington’s not really there, so it’s technically an amazing performance.’ He pointed out that the Queen had been given more lines than in her Bond debut, ten years previously, ‘partly because it was a lot cheaper to film her than to film Paddington’.

For Cottrell-Boyce, a devout Roman Catholic, the film had particular significance. ‘Paddington is an evacuee, a refugee, a one-time prisoner. Here, he is being welcomed with tea and good manners.

Queen Elizabeth and Prince Phillip, right, arrive at the London 2012 Olympics Opening Ceremony

Queen Elizabeth and Prince Phillip, right, arrive at the London 2012 Olympics Opening Ceremony

‘The most emotional moment in that encounter with Paddington is when the bear says, ‘Thank you, Ma’am. For everything.’ People will ask, ‘What everything?’ Well, make your own list. But I’m thankful for the way she used the peculiar power of her archaic role to allow us to glimpse, however fleetingly, that we share something good and we need to defend that.’

It later emerged that the Queen had experienced trouble with one particular line. Simon Farnaby, the actor who played her footman, recalls: ‘There was a bit where Paddington says, ‘I keep my sandwiches in my hat. I keep it for emergencies.’ She goes, ‘So do I. I keep mine in here,’ and she [indicates her] handbag.

‘At first, the Queen’s tone was quite harsh. The director would come in and say, ‘Ma’am, could you just be a bit gentler?’ And she’d be so sweet and she’d go: ‘I’m sorry, yes, of course.’ ‘He’d go: ‘Like you’re talking to your grandchildren.’ She’d say: ‘Oh, of course. I’m so sorry.’

The Queen was getting tired, but she eventually got the line right, and, according to Farnaby, ‘Everyone was relieved. It was OK in the end. It was really sweet and really lovely.’

Once it was all over, Farnaby congratulated the Queen on her performance. ‘I said, ‘Ma’am, that was fantastic.’ She went, ‘Oh, thank you.’ And I went, ‘You’re a very good actress.’ And she said, ‘Well of course, I do it all the time.’

‘I said, ‘Ooh, you mean like playing the part of the Queen?’ And she said, ‘I beg your pardon?’

‘And then I lost all my confidence. I thought she was giving me the scoop, like it’s a part, a role. I went, ‘I mean like it’s a role, isn’t it, the Queen, and you play it?’

‘And she said, ‘You know I am the Queen? Paddington’s not real, they’re actors. But I am the Queen.’