Boris Johnson has been accused of “flip-flopping” over whether to back Brexit or not, sendng conflicting signals to his former leader David Cameron as he prepared to make his decision.

A new book by one of Mr Cameron’s closest aides reveals that the day before publicly declaring his support for Leave, Mr Johnson sent a text to the then prime minister suggesting he would back Remain.

In the damning book by Sir Craig Oliver, Mr Cameron’s former communications chief, the Foreign Secretary is accused of having a “cavalier” approach to the issue.

The memoir, Unleashing Demons: The Inside Story Of Brexit, serialised in The Mail on Sunday, claims 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.

Boris Johnson goes 'off script' about when Brexit should happen

Sir Craig, handed a knighthood in Mr Cameron’s controversial resignation honours list, said: “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.

“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.

Also in the book, Sir Craig reveals Mr Cameron became intensely frustrated at Theresa May’s unwillingness to declare her intentions in the run-up to the EU referendum campaign, with some wondering if she was even an “enemy agent”.

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 of migrants coming into the country. But according to the book he was blocked by Ms 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.”