It could end really badly in Catalonia. Running out of their own ideas, the Spanish government in Madrid seems to be begging advice from ancestral Castilian spirits. And the ancestors say: “On with your breastplates, sharpen your halberds, show these upstarts who is master in our Kingdom.” Unless it can be stopped, what’s developing day by day leads to what General Jaruzelski did to Poland in 1981: tanks on the Ramblas, censorship of the media, mass internment of 10,000 “separatists”. And, almost inevitably, the blood of some “martyrs”. A European tragedy.

Or it could end, just possibly but only just, with a deal and a gate grinding open to Catalan independence. But even if that does happen, supposing most Catalans vote Yes in the referendum, there are many people in this country who will think it’s an even bigger European tragedy.

They will be wrong. In the broadest sense, the appearance of a Catalan state would be only another facet of a slow dismantling process emerging all over the world, pushed forward – surprisingly – by globalisation. And on a smaller scale, there’s something specially Iberian and something European about Catalonia’s travails.

Some nations associate democracy with centralism, aiming to overcome “provincial backwardness”. Jacobin France was one example. Labour in Britain, imposing the universal welfare state, was another. But Spain, especially in recent centuries, has been the opposite. As soon as the lid of oppression is lifted, every region demands autonomy – mild here, extreme there. And democracy and freedom are judged by how far devolution is granted by a new regime. Widespread self-government was dished out after the collapse of the Franco state in 1976. Now the Catalans want to go further. Neighbouring regions are torn between envious resentment of Catalonia and horror at Madrid’s drive to impose its will.

In a European focus, the race – or stumble – of the Catalans towards independence is anything but startling. Belgium, the Netherlands, the Czech Republic, Slovakia, Poland, Hungary, Slovenia, Ireland, all the Baltic republics, Finland, Norway… one could go on with this list of European states, many smaller than Catalonia, which pushed their way out of bigger nation-states and empires.

And Catalonia also belongs to one specially European category. This is the nationalism of “peripheral” regions that consider themselves much more developed than the “core” metropolis. The Czechs, with their new precision engineering, felt like that about snobbish old Vienna. Victorian Scots felt the same way about the “uneducated, forelock-tugging” English. The prosperous Catalans feel that arid, pious Castile still holds them back.

The puzzle is not why there are so many nation-states, but why there are so few. After all, there are something like (it’s guessing) 6,000 to 8,000 identifiable ethno-linguistic populations around the planet. That puzzle was formulated in the 1980s by Ernest Gellner, the father of grown-up thinking about nationalism. Today, there are still fewer than 200 nation-states, though the total is growing (the newcomers tend to get smaller).

But Gellner also said that “it is nationalism which engenders nations, and not the other way round”. Modern Spanish nationalism began in the 19th and 20th centuries, at the centre. In turn, it created modern Catalan nationalism, provoked by the contrast between the huge, disrupting impact of industrial capitalism on “developed” Catalonia and the political dominance of elites in Madrid.

And in “free Catalonia”, what sort of nationalism would it be? In England, in spite of the teaching of a whole school of post-Gellner historians, most people probably still think that “nationalism equals racism equals fascism equals war”. But in reality, nationalism in the past 100 years has been a spectrum. Ugly, xenophobic, self-pitying and mythmaking at one end; liberating, modernising, world-welcoming at the other. But all nationalisms have a bit of each extreme and everything depends on the proportions of the mix. Catalan national feeling is like Scottish in that it is “civic”, non-violent, opening impatiently to the new global world. It’s unlike Scotland – and more “ethnic” – in its passionate emphasis on Catalan language, history and culture.

Once independent, there’s no question: Catalonia would remain intimately linked with Spain. It’s not just the fact of mutual economic dependence (Catalonia produces a fifth of Spain’s wealth). It’s the countless ties of family and marriage and of the Spanish language and culture. That, again, closely resembles Scotland’s densely interwoven relationship with England, what Alex Salmond used to call “the social union” that, he insisted, would survive intact when the political union vanished.

If a government in Barcelona does declare independence, other Europeans would be insane to deny Catalonia EU membership. They may grumble at the idea. But if it happens, why launch a pointless, punitive “Caxit” expulsion that would deprive Europe of one of its wealthiest regions?

How many EU members, after all, have any serious problem with independence movements? Spain, the UK, Belgium, Italy with the Liga Nord, France with almost inaudible mutters in Brittany or Alsace. In other words, only five: old compound nation-states left over from the imperial age (Portugal and Germany are the exceptions). All five, when created, contained different ethnicities. True, some of the other 23 countries, mostly born out of the collapse of four empires in 1917-20, have tensions with their minorities – Slovakia and Romania with their Hungarians, for instance – but no threats of new prospective statehoods.

After 1989, most experts thought that globalisation would bring uniformity. Neoliberal free trade; the fade-out of petty nation-states (“divisive”), the hegemony of a few vast and benevolent powers. But the opposite happened. The spread of global culture and entertainment turned out to be the soil for a new crop of “petty nationalisms”. The Latvian boys and girls marching for independence from the Soviet Union sang forbidden folk songs, but wore Fruit of the Loom T-shirts.

As so often, uneven development was at work. Globalised turbo-capitalism didn’t pour steadily and pleasantly over the whole post-communist world. It crashed into societies at different rates with different impacts. Often, peripheral cultures felt that their core regions (Madrid, Rome, London) were treating them like colonies. To resist, they found new forms of political identity. The “British” arrogance of Mrs Thatcher’s policies brought Scotland’s independence movement to real credibility: just what Gellner meant by “nationalism creating nations, not the other way round”.

When I first saw Barcelona, it was in Franco’s time. Slinking about a grey, quiet city, I was taken to safe houses where Catalan intellectuals showed me forbidden writing in their own language. Today, 40,000 people roar that language as they besiege a law court. This could all end very badly. But the global tide is with them. And sooner or later, it will bring the Catalans to the harbour they need.