What a long distance David Cameron has travelled in the course of his party leadership. It is almost 10 years since he caused offence in Washington with a speech on the fifth anniversary of 9/11, in which he sought to distinguish himself both from neo-conservatives and from the presidential poodle that Tony Blair had supposedly become.

“We will serve neither our own, nor America’s, nor the world’s interests if we are seen as America’s unconditional associate in every endeavour,” he said. “Liberty grows from the ground,” he further insisted. “It cannot be dropped from the air by an unmanned drone.” In the White House, there were those who wondered what sort of friend to America this prospective prime minister could conceivably turn out to be.

They need not have worried. On Friday, “David” and “Barack” presented a united front that outstripped even the Bush-Blair double act in its informal bonhomie and aura of geopolitical bromance. Though the presidential itinerary encompassed birthday greetings to the Queen and Shakespeare at the Globe, Obama’s principal purpose was unambiguous – to shore up his friend and ally in the campaign to keep Britain in the European Union.

Cameron wouldn't last 30 seconds if he lost EU vote, says Ken Clarke Read more

Of course, the president’s intervention will backfire if it is perceived as an intrusion by the global elite in a private national argument – Goliath blundering into David’s boudoir. Fortified as he is by Obama’s visit, the prime minister is acutely aware that he cannot win this referendum as its predecessor was won in 1975. That contest was framed as a sane establishment defending common sense against a gang of loopy mavericks.

Now 41 years on, in the age of disruption, anti-politics and digital assaults upon authority, arguments only suffer by association with the establishment. So – on this occasion at least – Cameron is keen that his position should also be seen as the position of Jeremy Corbyn, the Greens and anyone else who usually loathes him. If he is to prevail, his campaigning coalition must embrace as broad an ideological spectrum as is possible.

Will it all be enough? As promising as the polls and the auguries appear for the remain cause, Cameron takes nothing for granted. For five years he held an implausible coalition together. A little less than a year ago he won a general election by a slender majority. This prime minister knows all about narrow margins, and how much they can mean.

It has become a mantra of the senior Brexiteers that he must not resign if he loses on 23 June. According to Chris Grayling, the leader of the house, it “would be disastrous” if the prime minister felt compelled to step down. Even as he announced his decision to back the leave campaign, Boris Johnson was equally emphatic that the vote had nothing to do with regime change. “Whatever happens at the end of this – and I’ve said this to the prime minister – he’s got to stay.”

Then again, what else could they say? The leave campaign cannot afford to be seen as no more than a Tory conspiracy, the first phase of a coup replacing Cameron with Johnson. It follows that the Brexiteers must be noisily loyal to the incumbent, in word if not in deed.

Facebook Twitter Pinterest ‘Remember how Cameron’s leadership was born: he arose from the ashes of the Tories’ 2005 defeat.’ Photograph: Andrew Parsons/PA

For all these protestations, it has long seemed to me that Cameron could not survive defeat and, no less to the point, would not want to. Last weekend, Ken Clarke was characteristically candid – and, I thought, correct – in his verdict that the prime minister “wouldn’t last 30 seconds if he lost the referendum”. I was surprised, therefore, to learn from members of Cameron’s circle that this is not how they see matters at all. Not a bit of it.

Suppose, for the sake of argument, that Britain votes for Brexit. Dawn breaks and Johnson and co hail a glorious victory for the British people, freedom and sovereignty restored. They are bound by their pre-referendum declarations not to call for Cameron’s head. But that does not stop the discreet collection of the necessary 50 names of MPs – 15% of the parliamentary party – demanding a vote of confidence in the prime minister. Indeed, it is clear from the speed of the submission that names were being collected well before the referendum. That’s loyalty for you.

Please note that this is not a leadership challenge. In spite of the obvious echoes, it is by no means a rerun of John Major’s resignation in 1995 and (successful) contest against John Redwood. In practice, its only precedent is the confidence vote lost by Iain Duncan Smith in 2003. At this stage of our hypothesis, all 330 Conservative MPs are invited only to register their support for the incumbent (or lack of it).

This EU battle has blurred the party lines – and they may never be clear again | Rafael Behr Read more

Cameron, it is true, is at his lowest ebb, defeated in a referendum in spite of cross-party support and the backing of the most powerful man in the world. Yet he can argue, plausibly enough, that this is a moment for continuity at the top rather than the additional disruption of a leadership contest. As his allies see it, the yearning of some on the Tory benches for his instant departure can be contained. “We have the numbers,” according to one prominent ally of the prime minister.

Let us return from the realm of conjecture to present reality. According to the polls, Cameron is heading for victory. But he is an instinctive contingency planner, cautious in his assumptions and rarely impulsive in his actions. If he loses, the weight of defeat may prove heavier than he now anticipates and he might decide that enough is enough. But – as things stand – that is not his strategic intention.

What is he up to? I think I have a hunch. Remember how Cameron’s leadership was born: he arose from the ashes of the Tories’ 2005 defeat, empowered by Michael Howard’s determination not to stand down as leader until an alternative to David Davis had been groomed.

If Cameron stepped aside immediately after defeat in the referendum, Johnson would be the strong favourite to succeed him. He might well remain so. But time is the enemy of all frontrunners: if the present Tory leader delayed his own departure, other candidates could arise and flex their muscles. At the very least, the range of potential successors would broaden. It would be a big mistake to imagine that Cameron is indifferent to who follows him. As the chess-playing president Josiah Bartlet used to say in The West Wing: look at the whole board.

•This article was amended on 26 April 2016 to clarify that Obama’s itinerary took in Shakespeare at the Globe theatre, rather than in Stratford.