Sir Craig Oliver said Mrs May failed to support Mr Cameron on 13 separate occasions before she did reluctantly “come off the fence” for Remain - and then only after a “visibly wound up” prime minster gave her a dressing down over the telephone.
In his book, Unleashing Demons: The Inside Story Of Brexit, serialised in The Mail on Sunday, Sir Craig also describes Boris Johnson’s “flip-flopping” during the weekend he finally came out in support of Brexit.
He said that the day before he made the announcement putting himself at the head of the Vote Leave campaign, the former London mayor warned Mr Cameron in a text he would be campaigning for Out, only to send a second text suggesting he could change his mind.
Sir Craig said Mrs May’s unwillingness to declare her hand in the run-up to the campaign had caused frustration in No 10, but he admitted that her low-key approach served her well in the aftermath of the vote for Brexit.
“Amid the murder and betrayal of the campaign, one figure stayed very still at the centre of it all - Theresa May. Now she is the last one standing,” he wrote.
He describes one conversation with Mr Cameron in January - six months before the referendum - after the then prime minister had sought to sound out Mrs May - who was then home secretary - about her views on the EU.
“It sounds like she refused to come off the fence. From her point of view it’s a smart strategy, trying to demonstrate she is her own person, allowing her to have her cake and eat it, but it doesn’t seem fair on DC, who has treated her well,” he wrote.
There was further consternation within No 10 when during a Cabinet discussion on the issue, Mrs May did not join in, “playing her cards close to her chest”.
“Her sphinx-like approach is becoming difficult, with the press questioning which way she will jump. The conversation turns around this being the biggest thing the PM has faced and him not even knowing if the home secretary is backing him,” he wrote.
Matters finally came to her after a report in The Times warning that Mr Cameron faces “last minute opposition” from Mrs May to his deal on EU reform.
“Later, on a train to Chippenham for a speech, DC is visibly wound up by the report. Suddenly he picks up his mobile and calls May, asking her to make clear we have been victorious in our plan to crackdown on ‘swindlers and fiddlers’ attempting to come into the UK,” Sir Craig wrote.
“When he hangs up he seems to think he’s made an impact. Later the Home Secretary issues a statement saying she believes there’s ‘the basis for a deal here’.
“This is interpreted as the moment she climbed down off the fence. After all the concern around her, it all seems to have ended not with a bang , but a whimper.”
Sir Craig also describes how the day before he came out for Brexit, Mr Johnson sent a text to Mr Cameron warning him that he would be campaigning for Leave, only to send a second message suggesting he could back Remain.
“I ask DC what makes him so sure Boris is wobbling. He reads out some parts of the text including the phrase ‘depression is setting in’, followed by a clear sense that he’s reconsidering. Neither of us is left in any doubt,” he wrote.
“I am struck by two things: Boris is genuinely in turmoil, flip-flopping within a matter of hours; and his cavalier approach.”
The following day Mr Cameron received a final text from Mr Johnson saying he would be backing Leave - just nine minutes before he publicly announced his intentions in a chaotic press conference outside his London home.
Sir Craig said that Mr Cameron later phoned him to say that Mr Johnson’s final message had been clear that he did not expect to win, believing Brexit would be “crushed”.
“He says Boris is really a ‘confused Inner’, and their previous conversations confirmed that view to him,” he wrote.
A second book, All Out War, by The Sunday Times political editor Tim Shipman serialised in that paper, claims Mr Cameron branded Mrs May “lily-livered” after she scuppered his plans for tough new immigration controls.
Mr Cameron wanted an “emergency brake” on migration as part of his EU renegotiation to help convince voters he would cut the numbers coming into the country.
But according to the book he was blocked by Mrs May - who was not prepared to take on German chancellor Angela Merkel - and the then foreign secretary Philip Hammond, now Chancellor of the Exchequer.
It quotes one Cameron aide as saying: “Hammond spoke first and argued we just just couldn’t do something that would receive an immediate raspberry in Europe. Theresa said very, very little, and simply said that we just couldn’t go against Merkel.”
A “visibly deflated” Mr Cameron was said to have turned to one official and said: “I can’t do it without their support. If it wasn’t for my lily-livered cabinet colleagues....”