Boris Johnson is a liar who only backed the Leave campaign to help his career and Michael Gove was a “foam-flecked Faragist” whose “one quality” was disloyalty, David Cameron writes in his memoirs.

The former prime minister poured vituperation on both his former colleagues Priti Patel, the current home secretary, and Dominic Cummings, the No 10 adviser, in extracts from the book published on Sunday.

In what may be Cameron’s most explosive allegation yet, he effectively accused Boris Johnson of mounting a racist election campaign by focusing on Turkey and its possible accession to the EU.

“It didn’t take long to figure out Leave’s obsession,” he writes. “Why focus on a country that wasn’t an EU member?

“The answer was that it was a Muslim country, which piqued fears about Islamism, mass migration and the transformation of communities. It was blatant.”

Then Cameron echoes the explicitly racist Conservative campaign slogan used in Smethwick in 1964: “They might as well have said: ‘If you want a Muslim for a neighbour, vote “remain”.’”

In Smethwick, Peter Griffiths had been elected as Conservative MP on the slogan “If you want a n**** for a neighbour, vote Labour.”

Cameron writes that Johnson’s claims of concerns about British sovereignty were “secondary to another concern for Boris: what was the best outcome for him?”

Johnson “risked an outcome he didn’t believe in because it would help his political career” and was open to a second referendum after a renegotiation, according to a Sunday Times account of Cameron’s book, For The Record.

Cameron is even more acerbic about Gove, who was once his close friend. Writing about Gove’s decision to stand against Johnson for Tory leader, he says: “As for Michael, one quality shone through: disloyalty. Disloyalty to me and, later, disloyalty to Boris.”

Their conduct during the EU referendum campaign amounted to “open warfare” and the pair seemed to be different people by the end, Cameron writes. “Both then behaved appallingly, attacking their own government, turning a blind eye to their side’s unpleasant actions and becoming ambassadors for the expert-trashing, truth-twisting age of populism.”

He said Patel’s attacks on his government’s immigration record “shocked me most” but he did not want to fire her and create a “Brexit martyr”. Cummings was part of a “cauldron of toxicity” with Nigel Farage, he says.

Reaction to Cameron’s memoirs has seen the former PM attacked by Conservatives from all wings of the party.

Brexiters were enraged by his suggestion that a second referendum might be necessary and that the Vote Leave campaign lied.

But Justine Greening, Cameron’s former international development secretary who now sits as an independent MP, said his decision to hold the EU referendum had proved to be a “horrendous mistake” that turned a Tory obsession into a national issue.

Greening said she had most concerns about how the Remain campaign was conducted, with major failings in an “elitist” Remain campaign that had failed to reach out enough sufficiently to young voters. “Patently, looking at the situation that Britain finds itself in now, as well as the Tory party, it was a horrendous mistake,” she said. “He took the one thing that divided the Tory party and managed to put it centre stage.

“The campaign was far too negative. It was quite staid, elitist, well-to-do. It needed to reach out far more to younger voters and talk about their opportunities, their futures. Instead they just played Ukip at their own game and lost.”

In the book Cameron says that he is “truly sorry” for the uncertainty and division that had followed the 2016 referendum, and in his first interview he suggested a second poll might be necessary. “I don’t think you can rule it out, because we’re stuck,” he told the Times.

The hardline Brexiter and former cabinet minister John Redwood said Cameron risked deepening national divides by wading back into the Brexit debate, and that he should be proud of having called the referendum, not ashamed of it.

“I don’t accept that,” he said when asked about Cameron’s claim that Vote Leave lied. “I don’t really think David Cameron reopening arguments in the referendum campaign is helping achieve what he says he wants to achieve, which is the country settling down again and accepting the decision it has made,” he told the BBC’s Today programme.

Cameron detailed his regrets about losing the referendum, but refused to apologise for calling the poll, and said that renegotiating Britain’s EU membership and holding a referendum was the “right approach”. However, the former prime minister’s re-emergence has unleashed a fresh debate about his role in the Brexit impasse and his motives for holding the referendum, including among many who were once close to him.

Michael Gove and Boris Johnson at a Vote Leave press conference in 2016. Photograph: Stefan Rousseau/AFP/Getty Images

Some Tories defended Cameron. Conservative MEP and hardline Brexit supporter Daniel Hannan tweeted: “Everyone agrees that David Cameron made a terrible blunder by holding a referendum. Everyone except, you know, the general population.”

Sir Malcolm Rifkind, the former defence secretary, said that an EU referendum had become inevitable. He said Cameron’s major mistake had been promising to renegotiate EU membership without any guarantees that he would secure major concessions. “I don’t think it was a question of Cameron being right or wrong – I don’t think he had much choice and was unlucky on the timing,” he said. “He has always been a bit of a gambler. The gambling worked in the Scottish referendum and not in this one.”

Cameron’s revelation that he smoked cannabis at school and later with his wife, Samantha, drew criticism over his perceived failures on Britain’s drugs policy.

Labour MP David Lammy asked why he had not used his time in power to change laws that penalised many young people for the same drug use Cameron wrote about in his memoir.

“Listen stoner why didn’t you use your privilege to do something about the working class young people who have ended up banged up, jobless and with a criminal record for smoking weed like you,” Lammy wrote on Twitter.