David Cameron says the Queen told a small gathering she hoped Scots would "think very carefully" about voting in favour of Scottish independence.
Recalling the time he met the royal family during the lead up to the referendum, the former Prime Minister said was "delighted" after she made a speech.
He also described Alex Salmond as the "slipperiest of characters" in exerts from his book For The Record.
In passages published in the Sunday Times, Cameron wrote: "Two weeks before the vote, I arrived in Scotland for my annual visit to Balmoral. Shortly I'd be having an audience with the Queen: she, the woman who had reigned over the UK for 62 years; me, the man who had allowed a vote on its possible disintegration.
"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."
Cameron recalled meeting Alex Salmond for negotiations on holding a referendum on Scottish independence.
He wrote: "I went up to Edinburgh for my first negotiation meeting with the slipperiest of characters, Alex Salmond, Scotland's first minister, in February 2012. I always used to say you had to count your fingers on the way out of a meeting with him. The negotiations dragged on — at one point it really seemed the referendum wasn't going to happen, and that his plan was to use the failure to get a deal as yet another argument for independence. But by October it was back on and, during a short meeting at Salmond's office in St Andrew's House, we signed the agreement."
After Alex Salmond conceded defeat, Cameron writes: "There is a lesson here for those wondering how you deal with the rise of populism. We could easily have ignored the separatism peddled by the SNP. We could have maligned the party and its form of nationalism. Instead, we identified the anti-establishment sentiment early on, confronted it and took the necessary risks.
"That was good for our country. But it was also good for our party. By driving a "respect" agenda, by holding the referendum, winning it and completing the devolution settlement, we sparked a Conservative revival no one had thought possible."
FOR THE RECORD IS PUBLISHED BY WILLIAM COLLINS ON THURSDAY, PRICED £25