The first group that tried to build the barricade were schoolkids. They linked the crash barriers together across the alleyway and tied them with an inch-thick cable. The next group, young men with wispy stubble and girls in hoodies, expressed contempt: they wanted to heap the barriers on top of some bags of cement instead. As they discussed the options, a third group arrived, dismantled the original structure and rebuilt it as a 20ft-deep fascine.

This was at the Escola Industrial on Sunday evening, a university complex serving as a polling station in Catalonia’s independence referendum. The vote had been deemed illegal by the Spanish state, but mandatory by the Catalan government, whose majority had been constructed around a single issue: independence or bust.

By now images of police violence against peaceful voters, old and young, were zipping across social media. Old people pulled to the ground; fleeing women hit with batons; a man jumped on down half a flight of stairs by a fully armoured riot cop . These pictures were horrifying Europe, but the thousands of people milling in the school courtyard did not look frightened or surprised.

Catalonia referendum: president calls for mediation with Spain over independence dispute Read more

After the referendum on Scottish independence in 2014, and the Greek vote to reject austerity in June 2015, people who resist the economic and social order in Europe know that state-backed scare tactics are part of the deal.

Though brutal, the Guardia Civil actions on Sunday were calculated: in the selection of riot squads from outside areas, where casual hatred of Catalans is rife; in the targeting of old people and women; and in the pinpoint nature of the interventions, which people on the barricades thought were concentrated on middle-class areas.

There were thousands of riot cops on hand, on ships in the harbour. If Madrid had wanted to, it could have confiscated every ballot box within minutes and, for good measure, jammed the smartphone app the Catalan authorities were using to tally the results against the electoral roll. But prime minister Mariano Rajoy wanted to send a subtler message: let the most fervent separatists have their vote and get their heads broken, while scaring the rest of the population into non-participation, including any waverers.

At the six polling stations I visited in the north and east of Barcelona, only one had been shut down. Behind the smashed window of the Joan Fuster community centre were two 15-year-old boys in baseball caps, guarding a single ballot box they had hidden from the riot police. But voters had simply moved to other polling stations: the back end of the queue for the nearest one was just yards away.

For the whole day voting was slow, because the websites were being jammed, said election officials. But it still happened. That’s why, amid the baton slaps and rubber bullets, two million people managed to cast a countable vote, with 90% voting Yes to independence. And as they voted, it looked to me like a modern cosmopolitan nation was being born. That’s a rare event in the era of globalisation, but it might not be the last.

Facebook Twitter Pinterest People who resist the economic and social order in Europe know that state-backed scare tactics are part of the deal. Photograph: UPI / Barcroft Images

In the El Clot district, a working-class suburb whose dense street pattern echoes its medieval origins, the polling stations were so close together that one line of a thousand people waiting to vote snaked around the block while across the street was another line for a different venue. In the few yards between the two queues, real democracy was happening.

People stood in the rain and talked in small groups – without hand gestures or raised voices – about what to do. This street-space, with its tobacco and occasional marijuana fumes, populated by wet dogs, irate pensioners and council officials demanding everyone switch their phones to airplane mode to reduce traffic to allow the voting app to work, was alive with democratic argument. If there was a consensus, it was that Catalonia should declare independence by nightfall, and have done with Spain.

If such a move seems illegitimate, backed by two million out of a potential 5.3 million votes, and in a technically disrupted poll, you have to weigh the quantity of democracy against its quality. What I saw in El Clot, and in the other districts, corresponds so closely to the original Athenian form of democracy that the parallel is worth exploring.

The Athenians had equal rights, an equal voice in the assembly, and they voted in “demes” – small geographic units. They possessed a popular literacy – in which the language of literature and drama, of the economic elite, was comprehensible to the people. Of course, women were excluded, and so were slaves – a social apartheid that tarnished the “ideal”.

In Catalonia on Sunday I saw something like a true democratic participation – and that should make the world, and the EU, think twice before dismissing the whole thing as a nationalist stunt.

Facebook Twitter Pinterest Riot police prevent people entering the Ramon Llull school to vote. Photograph: Alberto Estevez/EPA

Alex, an 18-year-old law student on the barricade at the Escola Industrial told me that, for him, this was not about flags, nor even language: he saw a Catalan-sized state, free of control by the Spanish financial elite, as the best way of protecting and enlarging his human rights. “Drets humans, drets humans” – I heard that phrase buzzing through tens of conversations.

Given the fascist-style response of the police, and the incendiary claim by Rajoy that police had acted “serenely”, you can see the Catalans’ point. By going peacefully on to the streets for hours, and creating in their own communities a real democracy of co-existence, tolerance and pacifism, they showed that the quality of their democratic culture was far greater than that of the closet Francoists and Opus Dei types who pull the strings in Madrid.

But they still face the same problem the Athenians did; whereas ancient Athens had slaves and disenfranchised women, the Catalans have a million foreign residents who can’t vote. There are tens of thousands of people in Catalonia who do not speak Catalan by choice; including the 10% of over-75s who say they cannot understand it. Plus there are up to a million non-Spanish residents – ranging from the African merchandise sellers on the street corners to the language students, from places as diverse as Japan and Wales, who hung out banners from their halls of residence declaring “We are with you Catalunya”. Though a growing number of foreigners do understand Catalan, they are a minority.

If the Catalan claim to self-determination rested on language, folklore, the ability to dance the Sardana, it would be poorly rooted in 21st-century reality. Big, successful cities like Barcelona are always open; you will always have to allow for Spanish speakers and foreigners to live, work and settle here – and to have a full stake in the polity.

But Catalan nationalism has made a sustained attempt to reconcile itself with the globalist and cosmopolitan ideologies of modern Europe. It was Montserrat Guibernau, visiting professor at Pompeu Fabra University Barcelona and one of the leading academic authorities on 21st-century nationalism, who coined the term “cosmopolitan nationalism”: a sentiment echoed in the last big demonstration before the vote, in Plaça de Catalunya on Friday night, when migrants and refugees were invited on to the stage to join a procession of “typical” members of Catalan society.

If Catalonia does declare independence this week, or sets a clear timeline for it, the success of the whole project will depend on its ability to embody cosmopolitanism – which in turn will depend on whether the generation that built the barricade can imprint their values on to the nationalism of their elders.

Play Video 0:48 Spanish PM open to talks with Catalan separatists – video

The Scottish, Greek and Catalan revolts were all driven in part by the failure of the economic model. In 2014, 45% of Scots believed they could better secure their rights, culture and economic future free of Westminster; in 2015 62% of Greeks voted to defy the economic logic of the Eurozone; now two million Catalans have braved the threat of a police boot in the face to demand independence within both the EU and the Eurozone.

This creates future challenges both for Britain and the EU. The SNP, Plaid Cymru and Sinn Féin all sent observers, invited by the Catalan government, as did the Liberal Democrats, whose leader Vince Cable condemned the repression. Fresh from a tour of the polling stations, Eoin Ó Broin, an Irish parliamentarian for Sinn Féin, was scathing about the EU’s silence: “Nobody expected them to comment on the substance of the referendum,” he told me. “But there is a genuine shock here at the absence of condemnation of the denial of the right to have the vote in the first place, and the brutality of the police and the use of digital methods to disrupt the vote. I am shocked that nobody in Brussels thought this was unacceptable.”

The presence of Sinn Féin and its strong support for the Catalans is not academic. The Anglo-Irish agreement includes the pledge of an all-Ireland referendum on unity – and by the middle of the 2020s it is likely that anti-Unionist voters will become the demographic majority in Northern Ireland.

Catalonia’s claim to self-determination is strong – and should have been tested in a legal referendum. Instead, the whole crisis has been driven by Madrid’s attack on autonomy, itself driven by the need to impose austerity during the Eurocrisis.

It is tragic to see European centrism, which once understood the principle of self-determination, ready to dilute it in the face of EU rules and economic rationality, and diplomatic compromise with a mendacious politician like Rajoy. Because progressive nationalism is not going away.

From George Square in Glasgow to Syntagma Square in Athens, there was always a Catalan flag waving above the crowd. I never understood until now that those flags were an essential part of the story. The “breakup” narratives of modern Europe – whether they are pulling away from nation states, currencies, free movement zones or the EU itself – are all driven by a central fact: the current settlement does not work.