Their only MP is a “dullard” who needs to be expelled, says the party’s millionaire backer. Their leader, Paul Nuttall, has been exposed as a fantasist. Their MEPs are under investigation for misuse of funds. They may have got 3.8m votes in the 2015 election but, today, Ukip is a political catastrophe.

Make no mistake: despite losing Copeland to the Conservatives, Labour well and truly stuffed Ukip in Stoke-on-Trent. The level of political pressure it applied to Nuttall effectively broke him. Among a population so turned off by mainstream politics that almost two thirds did not vote, Labour won a battle of the narratives. Anti-racists and democrats from all political parties can learn from this.

Ukip is in trouble because the Conservatives have become the party of Brexit. Without Brexit as its guiding narrative, the question posed for the racists, xenophobes and haters of Islam who populate the ultra-right online ecosphere is: what exactly is your project now?

The answers range from boycotting stores selling halal meat and fighting the “anti-white racism” of Diane Abbott to boycotting Walkers crisps.

Walkers has been targeted because of the anti-racist views of its public face, footballer Gary Lineker. Ukip spokesman Patrick O’Flynn tweeted last November: “Do Walker’s [sic] Crisps officially disapprove of those not holding a Lib-Left view on issues like immigration? Could hit their market share if so.”

During the byelection, anonymous Tweeters such as @northerncomment – a hate-spewing account followed by O’Flynn – were still chuntering about a boycott of Walkers.

The boycott never actually has to happen. In the dark online universe of Ukip supporters, spurning Walkers crisps just becomes one of its many signifiers of racism and xenophobia. Another is “animal rights” – code for the party’s campaign against halal meat. While Ukip policy is to ban non-stunned slaughter, supporters online are up in arms about having to shop in stores that sell it.

Of course, no party can control what its members or supporters say and do online, so this division of text and subtext cannot be laid at the door of either Nuttall himself or the party’s lone MP, Tory defector Douglas Carswell. But Labour’s strategists understood – as do the grassroots Labour supporters who have to put up with it in their pubs and clubs – that the relentless oxygenated racism of some core obsessives could be used to undermine Ukip.

Ukip’s broad support has been composed of perfectly ordinary people. The 3.8 million who voted for the party in 2015 felt excluded from mainstream politics; dumped upon by their (often Labour) local council, they saw industrial jobs destroyed by globalisation and, for some, their town disrupted by rapid inward migration. “Left behind” is the phrase most used to sum this up.

It is possible to feel all of the above and not be racist. Yet Ukip – from the very beginning – played a racist descant on top of this tune of justifiable grievances. Although always subtle and expressed within the law, this created the environment for the hardcore fascists and Ulster loyalists to amplify the message with hate speech and fake imagery.

In Stoke, Labour set about separating Ukip’s peripheral vote from the obsessively racist elements in its core. Local activists patiently confronted them with reality: that some Ukip activists are obsessive hatemongers; that the party has no coherent programme even to achieve the thing it wants – hard Brexit; and that no decent person should be associated with it.

Not only did Ukip’s vote fall. By the end – after Nuttall’s Hillsborough gaffe and his dire party conference speech – a new theme emerged in its discussion groups online: what is the point of going on? Party activists have realised that, with Theresa May now set on a hard Brexit, the issue of Europe can no longer play its role in their ideology as universal signifier of all that’s bad with Britain.

So the party is at a crossroads. It’s clear which way the ultra-right community around Ukip wishes to go: their timelines are full of praise for Marine Le Pen and Geert Wilders, and blazing with imagery – both real and fake – of migrant riots in France and Sweden. They want a war with tolerance and modernity.

Meanwhile the Trump faction – Arron Banks and Farage – are preparing to be rid of their troublesome working-class supporters. With luck, the unresolvable dilemma will destroy Ukip.

Amid Labour’s justified grief and recriminations over Copeland, it would be a pity if the lesson of Stoke got lost. The lesson is: it is right to stigmatise far-right racism without mercy; to call out the ignorance and racism of many Ukip activists; to offer people a radical break from politics done on the oligarch’s yacht, or in a box at Covent Garden. It is essential to offer the mass of Ukip voters a route back to mainstream politics, whether of the Labour or Tory kind.

By defeating Ukip, Labour and all other democratic parties drew a line through Stoke on Thursday night. It is the line that separates people who simply want more sovereignty and less migration from those who want to stigmatise halal, boycott Walkers and ignite the flames of racial conflict.

This latter group, a minority with small minds but huge ambitions, has declared war on the values of the progressive half of society. Stoke shows they can be beaten.