Image copyright Getty Images Image caption The referendum campaign has been "painful" for Michael Gove and David Cameron

The referendum campaign is splitting the country, tearing the Conservative Party asunder and, as Nick Robinson explains, has divided two formerly close friends - Prime Minister David Cameron and Justice Secretary Michael Gove.

They were once the closest of friends, men whose families holidayed together and who shared tables at their children's school quizzes.

They are now political enemies locked in a battle which will shape not just the future of their country but which could terminate the career of the prime minister.

"I think it's very painful for everybody involved," says Danny, Lord Finkelstein, Times columnist and friend of Mr Cameron.

Tough talk

To the public, Boris Johnson may seem to be the face of the Leave campaign but in private Mr Gove is its brain.

It was his decision to split with the prime minister that transformed this referendum.

The writer Petronella Wyatt has known both men since they were in their 20s. She says that as the first senior Tory to come out for Brexit, Mr Gove stole a march on Johnson.

"That was a thunderbolt, tanks on Cameron's lawn."

Image copyright Oli Scarff/Getty Images Image caption Steve Hilton says the Cameron-Gove friendship extends beyond politics

Those tanks have been exchanging heavy artillery. Terms like "liars", "defeatists", "traitors" have come fast and furious. Not words normal people use about their friends but then, of course, politicians are not normal people.

Perhaps you may be thinking they are not really friends at all but you would be wrong.

"It's a deep friendship," says Steve Hilton, once Mr Cameron's closest adviser in Number 10.

"It's about spending time together with their families, with their children, going on holiday together and they love loads of things outside politics.

"In fact the friendship probably doesn't even derive from politics, it derives from something deeper than that."

Conservative versus Radical

Yet they are very different politically. David Laws, Mr Gove's former deputy at the education department, points to the difference between Cameron's small 'c' conservatism and Gove the capital 'R' radical.

"One Conservative MP I think described Michael as like a mixture of Jeeves and Che Guevara," he says.

Image copyright Sky Atlantic Image caption The pair share a fondness for Game of Thrones

"The man who had not only Margaret Thatcher's picture on his wall but also Lenin and Malcolm X."

Danny Finkelstein thinks their choices over the EU demonstrate their differing political instincts.

"It's a tiny crack between their ways of working and their political perspectives and, as is often the case, like a little chip in the windshield, it can crack," he says.

Crack it certainly has and, perhaps, Mr Gove always sensed that it might.

He sees himself less as a latter day revolutionary and more as a real world Tyrion Lannister from the fantasy series Game of Thrones.

Demotion fallout

Mr Gove once described his favourite Thrones character as "this misshapen dwarf, reviled throughout his life, thought in the eyes of some to be a toxic figure, can at last rally a small band of loyal followers".

Or was he - in reality - describing himself? A toxic figure, reviled, was precisely how Mr Gove came to be seen as education secretary. Precisely why he was sacked from the job by his "friend" the prime minister.

When Mr Gove was made chief whip, Mr Cameron, a fellow Game of Thrones fan, told him he would be the Hand of the King - in other words his closest adviser, his number two.

Image copyright PA Image caption Michael Gove's wife, Sarah Vine (right), gave a less coded reaction to his demotion

There was just one problem. We in the media were told Gove had been demoted, he was not a full member of Cabinet, he would take a salary cut.

Gove reacted on Radio 4, saying: "Demotion, emotion, promotion, locomotion, I don't know how you would describe this move, though move it is, all I would say is that it's a privilege to serve."

His wife - the Daily Mail columnist Sarah Vine, who is godmother to the Camerons' youngest daughter - was a little less coded.

She tweeted a link to an article by a fellow hack describing "a shabby day's work which Cameron will live to regret".

For Petronella Wyatt, the episode was a moment for Gove when David Cameron had stopped behaving like a friend and so stopped deserving that loyalty.

"I believe Cameron has been treating him a bit like an under-butler," she tells me.

'Agonising struggle'

For a long, long time before this referendum was called, Mr Gove insisted in private that he would not, could not, abandon his friend.

That is what he told a lunch organised by Rupert Murdoch's News UK. It led Murdoch to use Twitter and editorials in The Sun to urge the man he once employed to put loyalty to his principles first.

This is how Ms Vine wrote about his struggle: "Michael has been like a cat on a hot tin roof, locked in an internal struggle of agonising proportions... The PM was genuinely, and quite naturally, shocked and hurt."

It was a decision that did not just hurt Mr Cameron. It convinced Mr Johnson, the man who confessed he had been "veering all over the place like a shopping trolley" to veer towards Brexit.

Image copyright Getty Images Image caption Michael Gove came out for Brexit before Boris Johnson

It was a dinner with Mr Gove at Boris Johnson's house, which led Mr Johnson to finally declare for Leave.

It is a dinner that may have helped to seal the fate not just of Britain, but of Mr Cameron as well. Or could friends be reunited after next week's result?

Danny Finkelstein thinks that though their relationship will never be the same again, the old alliances will re-emerge more than most anticipate.

But, he adds, if the UK does vote to leave the EU, Mr Cameron will be gone as prime minister.

Anthony Seldon, historian of Downing Street and its occupants, notes of Mr Gove: "I don't think it's his governing desire to become prime minister.

"I think he is a very intellectually driven person and, as we've seen here over Brexit, it is the ideology that trumps the bonds of friendship that existed not just between the two men, but between their wives also."

In just seven days' time, the country will decide whether Gove trumps Cameron and which friend will win the battle of Britain.