No wonder they were desperate that he keep his mouth shut. At his podium in Downing Street Barack Obama flattered his hosts, paid lip service to the notion that the referendum on British membership of the European Union on 23 June is a matter for the British people – and then calmly ripped apart the case for Brexit.

It was the Vote Leavers’ worst nightmare. For years – no, decades – the anti-EU camp has suggested that Britain’s natural habitat is not among its continental neighbours but in “the Anglosphere”, that solar system of English-speaking planets which revolves around the United States. Break free from Brussels and we could embrace our kindred spirits in Sydney, Toronto and especially New York, Washington and Los Angeles. The Brexit camp has long been like the man who dreams of leaving his wife for another woman, one who really understands him.

Obama is that other woman. And today he told the outers their fantasies were no more than that. First in print and then, more explicitly, in person he spelled out that America has no intention of forming some new, closer relationship with a Brexited Britain. On the contrary, a post-EU Britain would be at “the back of the queue” if it sought to agree its own, new trade treaty with the US.

America, he told his British audience – hence his use of “queue”, not “line” – likes the fact that Britain is already married: it works out really well for all three parties involved. His message was unambiguous. Don’t rush into a hasty divorce because you think we’re waiting for you with open arms. We’re not.

At a stroke, he had crushed not only a core part of the leavers’ economic argument – that it’ll be a breeze for Britain to exit the EU and trade just as prosperously as a solo nation – but something bigger: the notion that a brighter, non-European future beckons. Obama burst that bubble.

He also explained that of course he had the right to speak, despite Brexiteer Liam Fox’s letter signed by 100 MPs urging him to stay out of the EU debate. As Obama put it, since the leavers are offering “an opinion about what the US is going to do, I thought you might want to hear an opinion from the president of the United States on what the US is going to do”. And the opinion he gave was devastating.

That he had every right to speak is obvious, by the leavers’ own logic. He and the country he leads have been invoked as central to the alternative utopia that awaits us on Brexit. If he wants to tell us that utopia is an illusion, we need to hear it.

Hence the Brexiteers’ fury. They know how badly Obama’s words undermine their case, especially after what has been a week from hell for the out campaign. One that ended in the absurdity of a Ukip MEP, Mike Hookem, lurching into full-bore anti-Americanism, winding the clock back to 1939 to argue that the US had it in for us even then, seeing the second world war as a way of “smashing the UK’s influence in the world”. When a party defined by its loathing of the EU finds itself attacking the US, you know things have gone awry.

The same is true of Boris Johnson’s Sun screed, which dipped into Donald Trump’s Bumper Book of Political Wisdom to suggest that the “half-Kenyan” president cannot be trusted because he is filled with “ancestral” loathing of Britain.

What an interesting choice of word that “ancestral” was. Not “post-colonial”, which would have located this supposed antipathy in the 20th century, but “ancestral” to be run alongside “half-Kenyan”. It was a reminder of the brilliant slapdown Obama once issued to Trump, when the tycoon was demanding to see Obama’s birth certificate. From the podium at the 2011 White House correspondents’ dinner, Obama said he could go one better and show his birth video. He promptly played a clip from the Lion King, of Simba the newborn cub held aloft – as graceful a way of calling out a racist as one can imagine.

This, incidentally, is where the contortions of Brexit have left Johnson. It may still be true that the London mayor’s decision to back Vote Leave – when his elastic relationship with principle could just as easily have sprung the other way – was politically smart, all but guaranteeing the backing of the Eurosceptic Tory selectorate when they choose a successor to David Cameron. But it’s extracting a price.

Every day Johnson spends tag-teaming with Farage – who repeated his ‘half-kenyan line' – risks trashing the Boris brand

Once Johnson promised to be the face of metropolitan inclusivity, a Tory able to reach non-Tories by carrying less of their nasty party baggage. Yet this campaign is stripping away that gloss, reminding us that it was always a fake. Recall that Johnson once spoke of “piccaninnies” and wrote of African men with “watermelon smiles”. In the Spectator in 2002, he declared of Africa: “The problem is not that we were once in charge, but that we are not in charge any more.”

Every day he spends tag-teaming with Nigel Farage – who repeated the mayor’s “half-Kenyan” line – risks trashing the Boris brand, defining Johnson as less a future prime minister than a figure of the fringes, less a lovable maverick than a rather unpleasant oddball.

But it’s the wider Vote Leave campaign that has found itself in the wrong place. An anti-EU movement can’t also be anti-US, not without looking as if it hates everyone. Nor is it good to pit yourself against an American president who, whatever his domestic standing, remains in high esteem in Britain and Europe. It’s just too irresistibly tweetable to ask: if Obama’s for remain, and Trump and Le Pen are for leave, whose side are you on?

Above all, the core case advanced by the leavers on the US is flawed. Fox and others say Obama is a hypocrite because the US would never accept for itself the limitations on sovereignty demanded of Britain by the EU. But the comparison is silly. Britain is strong and rich, but it is also a relatively small country adjacent to a continent. The US virtually is a continent.

What makes sense for one would not make sense for the other. Besides, as Obama explained in Downing Street, the US does trim its sovereignty when it suits its purposes: it agrees to be bound by the trade rulings of the World Trade Organisation and Nafta, even if that means Congress is forced to back down on its own decisions.

All told, the Obama visit has been one of those episodes that say rather more than was ever intended. It says that this president retains a lustre even now, eight years on – one that only grows as you contemplate the contest to take his place. It says that, for all of the remain campaign’s problems, Leave now has to rebuild – after a dreadful seven days that began with Treasury numbers showing Brexit will make Britons poorer, and ended with a surgical evisceration from the world’s most powerful man.

And it said something about Britain’s relationship with the US. Ever needy to hear that we’re still special to the Americans, to hear that their president loves our queen and loves our talisman, Winston Churchill, we still listen to them – even when they tell us there’s no future for just the two of us together, that we need to stay in the marriage we’re in, even if sometimes it feels a little loveless.