Former Prime Minister David Cameron texted Boris Johnson to gloat after the now-Foreign Secretary was betrayed in his Tory leadership bid by Leave Campaign ally Michael Gove, a new book has claimed.

Mr Gove managed Mr Johnson’s campaign to be Mr Cameron's successor, before changing his mind the night before nominations were announced and running himself, forcing Mr Johnson to withdraw from the contest.

Mr Cameron, who campaigned to remain in the EU and resigned over the referendum result, texted Mr Johnson and said "you should have stuck with me, mate," following the debacle, author Tim Shipman has said.

In a book telling "the disastrous inside story of how Boris did not become prime minister", Mr Shipman reported that, following the Brexit referendum in June, Mr Gove initially agreed to back his colleague for the top job, despite the fact he was under "intense pressure from close allies" to run for the leadership himself.

But the relationship between the two politicians disintegrated over a series of mistakes and misunderstandings.

First, an email to Mr Gove from his wife was leaked. In it she urged her husband to get "specific assurances" from Mr Johnson and "not to concede ground", Mr Shipman said.

The email was posted online and went viral, damaging the relationship between the two men.

The situation reportedly worsened when an election strategist advised Mr Johnson to bring Eurosceptic MP Angela Leadsom on board, suggesting she could be helpful to his campaign.

Mr Johnson agreed and allegedly offered Ms Leadsom a top three job: deputy prime minister, Brexit negotiator or chancellor.

But, the book says, Mr Johnson became distracted when he encountered difficulties writing his campaign launch speech.

According to the book, he became so stressed by the task that he failed to ensure a letter was delivered to Ms Leadsom confirming his offer of an important position in his government.

Annoyed at the delay, Ms Leadsom reportedly texted Mr Johnson to say the deal was off.

Mr Gove “went ballistic", a source told Mr Shipman, and decided it was "too big a risk for the country" to allow someone as "incompetent" as Mr Johnson to become prime minister.

Over the course of the night, Mr Gove – who Mr Shipman said may also have been moved by speeches about how good a leader Mr Cameron was – decided he would put in his own leadership bid.

He reportedly told advisors: “I don’t have the luxury of time. Tomorrow I have to say to my colleagues and the country, ‘I think this man is ready to be prime minister’ and be held to account forever for having made that claim – or not”

Ten things Boris Johnson doesn't want you to know Show all 11 1 /11 Ten things Boris Johnson doesn't want you to know Ten things Boris Johnson doesn't want you to know pg-12-boris-2-pa.jpg BBC Ten things Boris Johnson doesn't want you to know Boris-Johnson-mother.png BBC Ten things Boris Johnson doesn't want you to know Boris-Johnson-boy.png BBC Ten things Boris Johnson doesn't want you to know Boris-Johnson-Great-Grandfather.png BBC Ten things Boris Johnson doesn't want you to know Boris-Johnson-Oxford-Union-President.png BBC Ten things Boris Johnson doesn't want you to know Boris-Johnson-Allegra.png BBC Ten things Boris Johnson doesn't want you to know Boris-Johnson-Bullingdon.png BBC Ten things Boris Johnson doesn't want you to know Boris-Johnson-Bullingdon-2.png BBC Ten things Boris Johnson doesn't want you to know Boris-Johnson-young-man.png BBC Ten things Boris Johnson doesn't want you to know Boris-Johnson-Petronella-Wyatt.png BBC Ten things Boris Johnson doesn't want you to know anish.jpg PA

When he first heard, Mr Johnson reportedly did not believe Mr Gove had decided to run, but when he realised the news was true he decided he could no longer stand in the contest.

He said later: “To go on would have been very bloody, and with Gove’s knife in my back it would have been hard to pick up momentum again with colleagues.”

The book claims one person who was with Mr Johnson when the nominations were announced said: “I’ve never seen him so winded. He looked utterly crushed. It was not the realisation it might all be over; it was just the betrayal”