In a bombshell revelation, which breaks with conventional protocol, he admits he asked if the monarch would "raise an eyebrow" in support of Better Together after a shock poll put the Yes campaign in the lead for the first time, just 11 days ahead of the vote.
In a two-part BBC series looking at his premiership, Mr Cameron reveals that he communicated with the Queen's Private Secretary about how she might be asked to show her support for keeping the union together.
Mr Cameron was staying at Balmoral when the poll findings were revealed in a Sunday newspaper, and he says the result was like a "blow to the solar plexus” and led to a “mounting sense of panic that this could go the wrong way.”
He says: “I remember conversations I had with my Private Secretary and he had with the Queen’s Private Secretary and I had with the Queen’s Private Secretary, not asking for anything that would be in any way improper or unconstitutional but just a raising of the eyebrow even you know, a quarter of an inch, we thought would make a difference.”
As a result, just four days before voters went to the polls, the Queen made a rare intervention, telling a well-wisher outside Crathie Kirk that she hoped people would "think very carefully about the future".
The remark was welcomed by No campaigners, as it received widespread press coverage. Mr Cameron says: “It was certainly well covered [by the media], although the words were very limited, I think it helped to put a slightly different perception on things.”
The revelation again jeopardises the Queen's traditional political neutrality - which Mr Cameron had also previously thrown into doubt.
In the aftermath of the No victory, he was overheard telling businessman Michael Bloomberg, that the monarch "purred down the line" at news of the result. He told Mr Bloomberg: “The definition of relief is being the Prime Minister of the United Kingdom and ringing the Queen and saying: ‘It’s alright, it’s OK’. That was something. She purred down the line.”
The SNP declined to comment on Mr Cameron's latest revelations, with a party source saying they had been "unfazed" by the Queen's remark at the time, and were now "focused on the future, not the past".
However, former First Minister, Alex Salmond said: “Begging a constitutional monarch to make a political intervention is not only totally improper but an indication of how desperate Prime Minister Cameron was in the final stages of the Scottish referendum campaign.
"Five years on Scotland should remember that Westminster does not recognise any political rule book. Cameron started the campaign uber-confident and ended up in a blue funk. I doubt if Scotland will let the establishment off the hook next time around."
He added: "As to Cameron’s suggestion that he was successful in securing a royal intervention, I doubt that.
"What I can vouch for is that the week after the referendum I was asked to meet the Queen at Balmoral. We discussed Cameron’s “purring comments” to Michael Bloomberg in New York in the aftermath of the referendum where he again blurted out what he claimed were her private thoughts.
"Unlike David Cameron I will not divulge what she said but suffice to say she was very far from amused at his behaviour.”
In his book, For The Record, Mr Cameron has also revealed how on the day of the poll which put the Yes campaign ahead, he had to prepare for an audience with the Queen "the woman who had reigned over the UK for 62 years" while he was "the man who had allowed a vote on its possible disintegration."
He wrote: “Of course, she was completely charming — the whole household was. But as Prince Philip showed me the barbecue he had designed to roast grouse and sausages up at the hillside bothy, the referendum was clearly on everyone's mind. They gingerly asked questions, but knew they shouldn't express too strong an opinion.
“And then, the next day at breakfast, there it was in cold print. Among the kippers and the kedgeree was The Sunday Times, with the headline "Yes vote leads in Scots poll".
“The Queen wasn't there — she usually had breakfast alone. Instead, I was surrounded by ladies-in-waiting, equerries and the moderator of the Church of Scotland. I tried to reassure them about "rogue polls", but I was struggling to convince myself, let alone them.
“One week later, however, the Queen spoke to some of those gathered outside Crathie Kirk and said she hoped Scots would "think very carefully" about the vote. I was delighted.”
His latest revelation comes in the BBC One series, ‘The Cameron Years’, which begins tonight, and which charts the key milestones of his political career, while also hearing from allies and critics who worked closely alongside him.
The series also sees George Osborne blame Cameron for feeding the idea "Brussels was to blame" for the UK's domestic troubles, and Michael Gove saying he thought Mr Cameron believed their friendship meant he wouldn’t "stray from the fold".
Mr Osborne also tells the programme he is “very sorry for what happened” and admits he feels “responsible” because of his role of Chancellor of the Exchequer, adding that “we held a referendum we should never have held” and “the consequences for the country are grave.”
He says: “I feel very sorry for what happened, and I feel responsible, I was the Chancellor of the Exchequer in that Government, we held a referendum we should never have held, we then lost that referendum and the consequences for the country are grave and the only thing I can plea in my mitigation is that a huge number of people wanted that referendum, and I made a case against it, but it wasn’t heard, and David Cameron was just one of a number of British Prime Ministers who had fed this idea that we were different than Europe, that Brussels was to blame and that the public ultimately had to have a say, and we’ve all paid a price for it in my view”.
Reacting to Mr Osborne's remarks, Martin Whitfield, Labour MP for East Lothian, said: “The Cameron/Osborne government got us into this mess and they must take responsibility for the economic hardship and divisions in society they have caused.
“Nationalists are always looking for someone else to blame, whether that be Scottish nationalists blaming Westminster, or English nationalists blaming Brussels. We need to build bridges, not erect barriers.
“The only way out of this mess is to give the people of the UK the opportunity to remain in the EU.”
In the programme both David Cameron and George Osborne also speak openly about the fraught conversations they had in the Downing Street flat, trying to convince Michael Gove to come down on their side.
Michael Gove says he felt “some of the conversations we had were attempts on his part to reassure himself that our friendship would mean that I wouldn’t stray from the fold.”
Mr Gove says: “I think David understandably felt that since I’d been prepared to knuckle under on a number of occasions beforehand and put my own feelings to one side in order to serve the team, that on this occasion, that I would do the same.”
Mr Cameron describes as a “bombshell” the moment when Gove said he would support the Leave campaign.
George Osborne remembers the moment he warned Gove “if you go to the Leave campaign you will destroy this Government, if we lose this referendum, David Cameron will have to go, there’s no way he’ll be able to survive, and everything we’ve worked on will fall apart.”
* The Cameron Years, is on BBC One tonight at 9pm. Part two, will be broadcast on September 26.