The regional elections in Bavaria resulted in a crushing defeat for the CSU party, which has ruled the province since 1950. It fell from almost half the votes to slightly over a third; at the same time its traditional rival (and partner in the national coalition government), the Social Democrats, did even worse and slumped to fifth place. The huge gainers were the Greens, now almost twice as large as the Social Democrats, and after them the anti-immigrant AfD in fourth place.

The CSU lost votes to both right and centre; more votes to the centre, in fact, than to the populists. But across Europe is it the populist parties that seem to be having their moment now. The word “populist” is a useful label, but it does not entirely explain the power of these movements. This cannot derive only from their most obvious feature, which is hostility to outsiders. There is also the sense of belonging that they produce by combining religion and nationalism to imagine, and so create, communities.

This is a deep human instinct. Children spontaneously do it in play. That does not make nationalism or religion primitive, though: in the forms that we know them today both are products of modern society. But neither is necessarily liberal or market-oriented. Both reject the ideal of freedom or self-sufficiency which suffuses the contemporary world. Both see that the individual derives her value from being part of a larger whole, rather than from being a fundamentally autonomous figure who must choose as freely as possible. In this sense, both are profoundly illiberal.

Why is this vision so attractive to so many? The most obvious answer is that it is at least half true. In a world where loneliness is such a huge problem that the British government has added the title of “minister for loneliness” to the burdens of the health secretary, and where the workings of the global economy are entirely unaffected by the sufferings of any individual caught up in them, it’s natural to understand that community and belonging are the only lasting stores of worth. Two more assertions of the importance of community make the populist vision attractive to some. The first is that you can’t easily choose to leave, or be thrown out. As with traditional families, membership in a populists’ community is not something you can ever wholly resign. “Home is the place where, when you have to go there, / They have to take you in” as Robert Frost’s poem has it – and the poem is itself an argument about the worth of a human being who no longer has any economic value. The second point is that this kind of belonging isn’t earned by any merit. As the poem goes on to say, home is “something you somehow haven’t to deserve”.

It may seem that the essence of populist parties is that they deny these rights to others. So they do. The danger is that they may have to do so. Since the belonging that they offer hasn’t been earned, it must be awarded on other grounds that have nothing to do with merit, such as birth, skin colour, or religious allegiance. All three are tangled together in contemporary populism. The AfD and parties to the east of it in Poland and Hungary – as well as the anti-papal Catholics of the League in Italy – use Christianity as a marker to exclude non-Christians and non-whites, all subsumed in the name “Muslim”. This need have nothing to do with theology. Many of the strongest voices for refugee rights in Europe are religious leaders. But Christianity is also a way of situating a community in history and it can be used to assert that strangers have never belonged here just as easily as it can urge that they be welcomed. In England, membership of the Anglican church correlates strongly with hostility to the EU; in the US, white evangelical Christianity is almost united in its support of Donald Trump.

How is the progressive left to combat this or to harness these longings to more generous purposes? The European welfare states were once available to all regardless of merit. The Greens still have a story of a better, transformative future to tell alongside the threatened apocalypse. The mainstream left must find its own.

• This article was amended on 16 October 2018 because an earlier version said Anglicans were hostile to Brexit, rather than to the EU. This has been corrected.