The bitter divisions between David Cameron and Theresa May over Brexit have been revealed in two books about the EU referendum campaign, in which May is described as “lily-livered” and an “enemy agent” by Cameron and his allies.

Cameron’s director of communications, Sir Craig Oliver, says in his exposé of Downing Street that the former prime minister’s advisers used the nickname “Submarine May” because she never came to the surface to support his efforts.

'Well, that didn't go to plan': Cameron's spin doctor on the Brexit vote Read more

In extracts from Oliver’s book, Unleashing Demons: The Inside Story of the EU Referendum, published in the Mail on Sunday, Cameron’s chief spin doctor says the prime minister pleaded with May to “come off the fence” about Brexit.

Oliver also describes how Boris Johnson “flip-flopped” between Leave and Remain before finally deciding to join the Brexit campaign, and he called Michael Gove a “political suicide bomber”, who had promised Cameron that he would stay loyal at a family gathering at Chequers at Christmas.

The second book, All Out War: The Full Story of How Brexit Sank Britain’s Political Class, by Sunday Times political editor Tim Shipman, claims May refused to support Cameron’s hardline approach to negotiations with EU leaders and rejected his plans to ask for an “emergency brake” on immigration – a stance Cameron described as “lily-livered”.

The two books are likely to emphasise divisions within the Conservative party over Brexit with former Cameron supporters coalescing around the former chancellor, George Osborne, who said last week he wanted to champion the “liberal mainstream majority”.

Oliver’s book is based on conversations with Cameron and Osborne, detailed notes from his time at Downing Street, and conversations with other politicians including Jeremy Corbyn, Boris Johnson, Theresa May and Peter Mandelson.

The former BBC News executive, who joined Cameron’s Downing Street team in 2011, says the prime minister became intensely frustrated with May over her unwillingness to declare her position before the referendum campaign.

Oliver says May failed to support Cameron on 13 separate occasions before she did reluctantly “come off the fence” for Remain.

After one conversation, Oliver wrote: “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. “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.”

After a newspaper report that Cameron would face “last-minute opposition” to the EU reform deal, the prime minister became “visibly wound up”.

Facebook Twitter Pinterest Former director of communications for David Cameron Sir Craig Oliver. Photograph: Toby Melville/Reuters

“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,” Oliver 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.”

Oliver also describes how Johnson vacillated between Leave and Remain, sending conflicting text messages to Cameron the day before he came out for Brexit. “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 Cameron received a final text from 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.

Oliver said that Cameron later phoned him to say 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.

Shipman’s account of May’s position tallies with Oliver’s. He says that on 27 November 2014, the day before Cameron made a major speech announcing his plan to renegotiate Britain’s relationship with the EU, the prime minister met May and Philip Hammond, then the foreign secretary, to outline his strategy.

Cameron told them he wanted to ask Angela Merkel and other EU leaders to allow Britain to limit the numbers of EU migrants – but both May and Hammond rejected the idea.