A WIN is a win is a win. Labour only held on to Batley and Spen by a whisker, but that will be enough for Sir Keir Starmer, whose job was, by common agreement, on the line in last week’s by-election. But it won’t halt the criticism of “Keith” as the Labour leader is often called by left-wingers in his party, who were almost as disappointed with the result as George Galloway.

Like most press commentators, they thought Labour was going down to another historic defeat and that Angela Rayner, Sir Keir’s deputy, would be the likely beneficiary in a leadership contest.

Left-wing Labour MPs had already been sounded out in Westminster about a Rayner challenge. Pro-Labour commentators, like The Guardian’s Owen Jones, while insisting they wanted Kim Leadbeater to win, had been openly calling for a leadership contest if she lost. Like many on the left, Mr Jones regards Starmer as a politician of “no vision and no politics” and precious little charisma leading a vindictive right wing faction who thinks defeating the left is more important than defeating the Tories. They thought that the Labour leader’s equivocation over the Palestinian cause would lose votes in constituencies like Batley, which has a large Muslim community. It probably did.

George Galloway, who made Israel’s bombing of Gaza a major plank of his campaign, did remarkably well here with over 8,000 votes. The Workers Party of Great Britain candidate is regarded as a three-time loser in Scotland, but Batley remembers him as the victor in the neighbouring Bradford West by-election in 2012. However, Mr Galloway had unwisely said he would eat his hat if Labour did not come third, and that did not come to pass. So far, his trademark fedora has remained unconsumed and he declared instead that he would contest the result in the courts. This only confirmed his critics in their view that he is a kind of leftist version of Donald Trump.

Throughout the campaign, scorn and obloquy was heaped upon Galloway, whom Labour tried to portray as a far-right demagogue. Activists fully believed that, in Batley and Spen, the only people who would benefit from his presence on the ballot paper would be the Tories. Mr Galloway did indeed succeed in winning far more votes than equalled Labour’s majority in the constituency. However, the irony is that he may also have split the Tory vote and allowed Kim Leadbeater to come through the middle.

As the Brexit and “anti-woke” candidate, who dared to challenge Labour’s transgender policies, some right-wing voters may well have decided to lend their votes to Mr Galloway. We will never know. But the one thing we do know is that this by-election was there for the taking for the Conservatives and Boris Johnson will be furious at failing to clinch it. Tory complacency, as well as Galloway’s populism, saved Keir Starmer’s skin.

The profile of the Tory candidate, Leeds councillor, Ryan Stevenson, was so low he was practically invisible. Unlike in Hartlepool, there was no local story about the Conservative Government bringing jobs to this “left behind” area of Yorkshire. Strategists evidently thought that keeping their candidate out of the firing line would guarantee them a seat where Labour were in all manner difficulties, and where Keir Starmer was unpopular. This was unwise in the aftermath of the Hancock scandal. On the doorsteps, voters complained less about the former health secretary’s adultery than the hypocrisy of his telling everyone to avoid hugging relatives when he was indulging in enthusiastic extra-curricular gropings in his ministerial office.

As the “white party” the Conservatives also thought it best to avoid getting involved in the culture wars in Batley. There was a stew of identity conflicts, not least over Palestine. The Conservatives were content to let Labour and Galloway knock lumps out of each other over Keir Starmer’s campaign against anti-Semitism, which many Muslim voters believed was diverting attention from Islamophobia in the Labour Party.

The Tories tried to keep above the fray on Kashmir also. Labour were criticised, by Labour Friends of India, no less, for a leaflet that appeared to be exploiting tension between Muslim and Hindu communities over the Indian prime minister Narendra Modi’s, alleged abuses of human rights in the disputed province.

This was all far removed from the people’s priorities in Batley. They were largely about local issues like pot holes, traffic congestion and the closure of the local police station. The Conservatives could have won this seat had they rolled their sleeves up and presented themselves as the sensible party concerned with voter issues, rather than with ethnic and religious conflicts in lands far away.

The Liberal Democrats, who knocked a hole in the Tory blue wall in Chesham and Amersham last month, were nowhere in Batley. They returned only 3 per cent of the vote, losing their deposit, despite being the archetypal party of localism and “community politics”.

Some Tories are consoling themselves that at least Keir Starmer will remain Labour leader. They think that because he’s been failing to make any impact, and presides over a divided party, he is their best bet for victory in the next General Election. A third defeat, after losing Hartlepool last month and losing a deposit in Chesham and Amersham, might have unseated him. However, that assumes there is someone on the Labour frontbench who actually is more popular with voters.

Had Labour lost, there would more likely have been an outbreak of old-fashioned Labour factionalism, as the left and right went to war over the succession. Nor is mouthy Corbynite Angela Rayner a particularly attractive alternative to Starmer’s dogged centrism. As it happens, Keir Starmer is probably the best the Parliamentary Labour Party has to offer right now, and the Tory failure in Batley and Spen has helped him consolidate his leadership. His confidence has been boosted and he will be able further to marginalise the left and lay the ghost of Jeremy Corbyn.

At the end of the day, and it was a long one, none of the parties can claim much credit for the fractious campaign in Batley. Only 48% of voters bothered to turn out. It was marred by accusations of dirty tricks, fakery and violent aggression.

The low point was Kim Leadbeater being harranged outside a mosque by anti-LGBT Muslim protesters. At first, Labour were horrified by this barracking of a gay candidate by members of an ethnic minority, but they later realised that it was good news for the campaign. Muslim voters are as repelled by this kind of conduct as white voters. Indeed, this episode may have been the turning point in the campaign.

After all, this was the constituency in which the Labour MP, Jo Cox, was murdered by a far-right terrorist. Ms Leadbeater is her sister, and she managed to retain her dignity while refusing to be intimidated.

She is, by all accounts, an extremely energetic campaigner and the only candidate who actually lives and works in the constituency. In a contest of multicultural and gender wars, she stood out as the least divisive candidate. Kim Leadbeater’s politics are opaque, but her decency was probably Labour’s best political asset.