It’s remarkable what you can learn in Slovenia. At a conference on politics, security and development in Bled earlier this year, I was lucky enough to chat to the Catalan delegates, proudly representing the interests and wisdom of their ancient principality. With considerable poise and dignity, they seemed to me to be channelling Pericles on the Athenians: we do not imitate, but are a model to others.

So I am not surprised that Madrid is as frightened as it evidently is by Catalonia’s unilateral declaration of independence. This is not a tinpot province threatening to secede as a means of squeezing a bridge or two out of central government. Recognised as a distinct political entity since the 12th century, it has always treasured its autonomy – lost under Franco and recovered after his death in 1975. Since Friday, its separation from Spain to become a fully functioning sovereign state, though still improbable, is quite conceivable.

Madrid appears determined to inflame separatist emotions rather than to seek a diplomatic solution to the crisis

This alone represents a terrible defeat for Mariano Rajoy, the Spanish prime minister, whose response was to order the sacking of the entire Catalan government, the closure of Barcelona’s ministries, the dismissal of Catalonia’s police chief and the dissolution of its regional parliament. Though Madrid has generously declared that Carles Puigdemont, the deposed Catalan president, is welcome to run in the snap election on 21 December, he remains, confusingly, at risk of arrest for rebellion.

There are all sorts of cogent arguments against secession – the best of which is that Catalonia itself is profoundly divided on the question. The region has a low credit rating, and debts that have more than tripled since 2009. It is not remotely ready to manage its own defence, currency, utilities, border controls and infrastructure. An absolute rupture from Spain would make Brexit seem a mere bagatelle.

Yet Madrid – aided by Brussels – appears determined to inflame separatist emotions rather than seek a diplomatic solution to the crisis. The independence referendum held on 1 October may have been technically illegal, as Spain’s constitutional court asserted, but the often brutal manner in which the poll was obstructed by the national police and Guardia Civil made such appeals to the rule of law seem like a preposterous fig leaf for street-level authoritarianism.

While the Spanish government pontificated, social media fizzed with shocking video of officers in riot gear using violence to prevent Catalan citizens from peacefully casting their votes. At that point, the question changed from “Is this referendum meaningful?” to “How are such scenes possible on the streets of a modern liberal democracy?”

Rajoy’s strategy has been spectacularly unnuanced. At every turn, he has scorned the independence movement as no more than a plot “to liquidate our constitution”, a “criminal” conspiracy, and “a clear violation of the laws, of democracy, of the rights of all”. King Felipe VI has loftily chastised Catalans for trying “to break the unity of Spain and its national sovereignty, which is the right of all Spaniards to democratically decide their lives together”. With dependable insensitivity, Jean-Claude Juncker declaredon Saturday: “There isn’t room in Europe for other fractures or other cracks – we’ve had enough of those.” The Brussels naughty step is getting rather crowded.

Because of Spain’s singular history, the integrity of the nation has special significance. In a country governed by a military dictator between 1939 and 1975, the threat of disaggregation and lawlessness is especially vivid.

But in an age of hectic change such as ours, history must be granted a vote rather than a veto. Bad memories may explain present errors, but they do not excuse them. And Rajoy is proving himself unequal to the moment. Simply asserting that the rules have been broken and will be enforced is a pitiful approach to a hugely complex cultural dilemma.

Take a step back: if the early 21st century has a unifying theme, it is that the rules-based order that seemed triumphant in 1989 faces a series of fundamental challenges. Prime among them is a burgeoning of the secessionist impulse, of tribalism and populist resistance to distant elites. In this era of disruption, nomadism and technological revolution, the appeal of place and space has returned. A longing for what Heidegger called wohnen – “dwelling” – is suddenly resurgent. In some instances, as in Charlottesville, this takes the form of a despicable blood-and-soil nativism. But the instinct is not always reprehensible. For Catalans to crave their own nation is not intrinsically wrong, whatever its impracticalities and inconveniences.

Those of us who still value rules-based internationalism have to acknowledge that not everyone is at ease on the rollercoaster of modernity. That much was made clear by last year’s EU referendum and the election of Donald Trump. The notion that politics is simply a branch of economics is no longer sustainable (if, indeed, it ever was). The issue of identity has assumed a fresh importance that we ignore at our peril.

It takes pathological form in the ugly “identitarian” movements of the European far right. But it also infuses the politics of the mainstream – from Catalan separatism to parliament’s scrutiny of the EU withdrawal bill. The primal need to belong, to be more than a tiny cog in a global machine, is asserting itself with astonishing force. As Sebastian Junger writes in his book Tribe: “Humans don’t mind hardship, in fact they thrive on it; what they mind is not feeling necessary.”

I am deeply suspicious of the populism that offers easy solutions to complex problems: secession, like hostility to immigration, cannot possibly be the panacea that its champions typically claim. I still believe in the liberal order, viable nation-states and the supranational agreements that make possible global collaboration between them. But it is idle to pretend in 2017 that this order is in especially good shape.

We are in the foothills of a formidable debate about its future, and how it should be adapted to address the inequities of globalisation, the transformative power of technology, and the fears of communities great and small that they will be swept away by the hurricane of change. If the Catalan crisis has a lesson to date, it is that Madrid’s answer – repressive constitutionalism, so to speak – is no answer at all. Saying the same, only louder, will not preserve the integrity of Spain or of anything else. In the unfolding of history, the greatest mistake is to believe there is a script.

• Matthew d’Ancona is a Guardian columnist