It wasn’t supposed to go like this.

When UK prime minister Theresa May called a snap election five weeks ago, the decision was widely portrayed as a masterstroke. The Tories, it was almost universally agreed, would romp home with a huge majority and a sweeping mandate for more savage austerity and a “hard Brexit”. Labour would be wiped out for a generation, if not for good. The Corbyn “experiment” would be finished, and the right would either take back control of Labour or break away to form a new centrist party that crushed the rump of Corbynites in parliament.

Now, only days out from the 8 June election, things couldn’t look more different. Labour is surging in the polls, some of which now predict the Tories will not win a majority. Even if Theresa May ends up winning, anything short of a significantly increased majority will likely doom her prime ministership. On the other hand, if Labour managed to win enough seats to form a minority government, it would create a political shock wave on the scale of last year’s Brexit vote, but this time the kind of shock that would provide a huge boost for the left in Britain and across Europe.

Well short of that, if even the worst polls (from Labour’s point of view) are right, the enormous shift to Labour over the course of the campaign has demolished the campaign run by the right wing of the party, and by its media backers at the Guardian and elsewhere, to sabotage Corbyn’s leadership and prove that any left wing challenge to the neoliberal order is doomed in advance.

Labour’s campaign has been unashamedly left wing, and centred on class issues. Corbyn set the tone in his first speech, declaring: “The dividing lines in this election could not be clearer from the outset. It is the Conservatives, the party of privilege and the richest, versus the Labour Party, the party that is standing up for working people to improve the lives of all”.

The Labour campaign slogan “for the many, not the few” is backed up by what has proven to be a hugely popular manifesto containing a raft of left wing policies including increasing taxes on the rich, pouring billions into education and the National Health Service, abolishing tuition fees, raising the minimum wage, ending attacks on social security recipients and trade union rights, and renationalising the Royal Mail, the water system and the railways.

In the Brexit campaign, the political division between the Leave and Remain camps – one side dominated by reactionary anti-immigrant racism and English nationalism, and the other by a pro-austerity neoliberal elite – paralysed the left and obscured the fundamental division in British society: class.

Many concluded from the Leave victory that whole swathes of the working class, particularly in the former Labour heartlands in the north, had permanently decamped to UKIP and the Tories. Most on the right of the Labour Party argued that the only way to win back such voters was to adopt wholesale the reactionary UKIP and Tory anti-immigrant policies. But Corbyn’s campaign has proven that a vigorous campaign that tries to unite people against their real enemies – the super rich and their Tory backers – can make real gains.

Predictably, the right wing press has run a relentless campaign portraying Corbyn as a crazed communist and supporter of terrorism. But from the start of the campaign Corbyn has also been sabotaged by his own MPs, and by other Labour figures like former PM Tony Blair who openly argued that voters should consider voting for non-Labour parties like the pro-austerity Liberal Democrats. The Guardian – supposedly the paper of the liberal left – has run endless articles explaining why Corbyn’s leadership was a disaster.

But as the Corbyn campaign gained momentum and the poll gap has narrowed dramatically, these critics have increasingly fallen silent. A week out from the election, the Guardian performed a remarkable backflip, editorialising (without a word of self-criticism) in favour of a Corbyn victory and running a series of opinion articles and campaign reports extolling Corbyn’s virtues.

The fact that these opponents of the Corbyn leadership have been forced into line reflects nothing positive about their political outlook, but is entirely a result of the success of Corbyn’s campaign. They can be relied upon to turn against him and the left again at the first opportunity.

That may not be far off. Whatever happens on 8 June, the election will represent the start of the struggle, not the end. If the Tories win reasonably narrowly, the new Tory government will be highly unstable and Corbyn will have immense political authority. But he will still face the reality that the majority of Labour MPs – even though many will owe their seat to his left wing campaign that they openly sabotaged – will remain bitterly hostile to him and his continued leadership. Indeed, the very success of Corbyn’s campaign will be just more evidence to the right, both in the Labour Party and outside it, that Corbyn is a serious threat to their interests and must be brought down.

And if Corbyn does pull off a remarkable victory, the challenges will only get greater. Even if Labour had the numbers to form a minority government, it would rely on parliamentary votes of MPs from both Labour and other parties like the Scottish National Party who at any time could defect to the Tories. And outside the parliament, the full force of the state apparatus, the media, the banks, the industry bosses, the military, the intelligence services and so on would be guaranteed to mobilise against any attempt to implement a radical left wing policy agenda.

The difficulties Donald Trump is facing with the so-called “deep state” in the US are nothing compared to the brutality with which the ruling class and its institutions would react to a government that threatened their class interests rather than merely their sense of dignity.

Whether Labour finds itself in opposition or in government, there will be immense pressure on Corbyn and his supporters to capitulate to the right, and a renewed struggle from the right to wipe out the gains he has made. The only way to resist such attacks is to steel the left for a protracted fight – inside and outside the Labour Party, in workplaces, on university campuses and on the streets.

Corbyn’s remarkable rise, from a radical oddity on the fringes of the parliamentary Labour Party to the leader of a crusading left campaign threatening to bring down a Tory government, is cause for enormous hope. It shows that the raw material for a challenge to the brutality of modern capitalism exists. It demonstrates that the hostility of millions of people to a system so palpably rigged for the rich is not doomed to end in the reactionary racism of Donald Trump or UKIP, but can be expressed in a left wing movement that puts class politics at its heart.

The challenge, whether Corbyn wins or loses, is to turn that potential into a force that can take on and defeat the defenders of austerity and reaction.