“The owl of Minerva begins its flight only with the coming of the dusk,” wrote Hegel in the Philosophy of Right. This was a poetic way of saying that wisdom and understanding only come with hindsight, and history never ceases to play itself out in unanticipated ways. As Germany marks the 30th anniversary of the fall of the Berlin Wall this weekend, a flapping of wings is audible.

After the extraordinary events of 9 November 1989, when east Berliners poured through the Wall’s checkpoints, calling time on the cold war and the communist era in Europe, many assumed that a definitive victory had been won for liberal democracy. Francis Fukuyama famously suggested the triumph of western values could signal “the end of history”.

China’s massacre of pro-reform protesters earlier that year pointed to alternative outcomes; and Mr Fukuyama has since revised his view. But for 20 years or so, Europe seemed to bear the verdict out. This was liberalism in excelsis. As the EU expanded eastwards, the former Warsaw Pact countries democratised, privatised state assets and grew considerably richer, despite economic pain and severe hardship along the way.

Yet three decades on from the destruction of what West Berlin’s mayor, Willy Brandt, called the “Wall of Shame”, the liberal consensus that swept all before it in the 90s and 2000s is suddenly fragile. This feels like a shadowed, equivocal anniversary. In eastern Europe, rightwing nationalist parties have flourished in the smaller towns and rural areas that have seen little of the wealth accrued in capitals such as Warsaw and Budapest, and have suffered as young people have upped sticks and left. Barriers have sprung up again: barbed wire fences keep out refugees and migrants on Hungary’s eastern borders. The country’s prime minister, Viktor Orbán, styles himself the champion of “illiberal democracy”, an authoritarian brand of nationalism that targets minorities and disdains the notion of universal human rights. In Poland, the Law and Justice party – re-elected for a second term last month – has defied liberal democratic norms to target judges and control the media. Close to Berlin, in the east German state of Thuringia, the CDU finished behind the far-right nationalist AfD in state elections.

The depressing emergence of an aggressive rightwing populist nationalism has not been confined to the east. The rise of Matteo Salvini’s League party in Italy, the support for Marine Le Pen in France and the Brexit referendum result can also be traced, in part, to flaws in the liberal thinking which remade Europe with supreme self-confidence after 1989. Too little attention was paid to the regions, places and individuals which lost out in the emerging single market, established in 1993. The fallout from the 2008 crash exposed the truth that though European societies grew wealthier over the last 30 years, they also grew more divided, as governments took a back seat and allowed market forces to dictate.

There are tentative signs that some necessary rethinking may be under way. The French president, Emmanuel Macron, shaken by the yellow-vest protests that began a year ago, has pledged to increase public spending, ignoring deficit warnings from Brussels. In an interview this week, he observed that “Europe has forgotten that it is a community, by increasingly thinking of itself as a market, with expansion as an end purpose”. He would like to see a common eurozone budget, with real fiscal firepower, to enable a fairer distribution of wealth and resources across the EU. The European Central Bank’s new president, Christine Lagarde, has called on governments with budget surpluses, such as Germany and the Netherlands, to spend more to stimulate pan-European growth. In Britain, both major parties are proposing 1970s levels of public spending ahead of next month’s election.

The fall of the Berlin Wall brought freedom and hope. But the veneration of free market principles that followed was overdone. With hindsight, the lessons of 1989 look different, telling us that a recalibration of the relationship between governments and the market is overdue, and might head off the nationalist surge in both east and west.