IF YOU look up from the bustle of the winter tourists thronging the streets of Barcelona, you will see some balconies draped with the estelada, a blend of the Catalan and Cuban flags that has become the banner of those who want their land to become independent. There are fewer than there once were, but still enough to inspire the Catalan regional government’s pledge to hold a binding referendum on independence in 2017. Since the Spanish government refuses to contemplate such a vote, a confrontation seems inevitable.

Indeed, it has already begun. Some 300 Catalan officials face court cases for flouting the law, in acts ranging from a previous unilateral effort in 2014 to organise an independence vote to petty protests, such as flying the estelada from town halls. Carles Puigdemont, the president of the Generalitat (the Catalan government), promises to push through “laws of disconnection” this summer, such as one setting up its own tax agency, prior to holding a referendum, probably in September. His pro-independence coalition has a majority in the Catalan parliament. On December 14th Spain’s Constitutional Tribunal warned the Generalitat that the referendum would be illegal. Spain could face unprecedented defiance of its democratic constitution.

How has it come to this? Spain’s constitution of 1978 gave Catalonia, one of the country’s most prosperous regions, more self-government than almost any other part of Europe. The Generalitat controls not just schools and hospitals but police and prisons. It has made Catalan the main language of teaching. Under Jordi Pujol, the skilful moderate nationalist cacique (political boss) who headed the Generalitat from 1980 to 2003, Catalonia was content with this settlement, using its votes in the Madrid parliament to extract increments to it powers and revenues.

Two things upset matters. The first was when the Constitutional Tribunal in 2010 watered down a new autonomy statute, which recognised Catalonia’s sense of nationhood and granted additional legal powers to the Generalitat. It had been approved by referendum in Catalonia and by the Spanish parliament. The second factor was the economic crisis after the bursting of Spain’s property bubble in 2008.

In 2012 demonstrators against austerity began to put the blame on Madrid, rather than Artur Mas, Mr Pujol’s heir. Support for independence surged from less than 25% to more than 45%. “Society moved towards more radical positions,” thinks Joan Culla, a historian. Others see this as at least in part induced by the Generalitat, with its money and powerful communications machine. It allowed the nationalists to keep power, despite budget cuts and revelations that for decades they had taken rake-offs on public contracts.

Catalan society remains split. “There aren’t the numbers to advance [to independence] but there’s enough to make a lot of noise,” says Jordi Alberich of the Cercle d’Economia, a business group.

Best of enemies

This stand-off has been politically profitable not just for the Catalan nationalists but also for Mariano Rajoy, Spain’s prime minister, and his conservative People’s Party. His staunch defence of his country’s territorial unity is popular in most places outside Catalonia. For years Mr Rajoy did nothing to respond to Catalan grievances, some of which are justified. Catalonia pays more into the central kitty than it gets back, but its transport systems have been neglected while Madrid has spiffy metro lines and a surfeit of motorways.

Yet weariness with the deadlock has taken hold, in both Barcelona and Madrid. Last month Mr Rajoy put his deputy, Soraya Sáenz de Santamaría, in charge of the Catalan question. She is putting feelers out to the Generalitat. Mr Puigdemont has published a list of 46 points to negotiate. It starts with the “binding referendum”.

It is not hard to divine the contours of a deal. Mr Rajoy could offer concessions on financing and infrastructure. More controversially, he could propose recognising the Catalan language or that Catalonia is a nation within Spain.

The toughest issue is the referendum. This is no moment to contemplate any sort of plebiscite with equanimity. Catalan nationalists claim to be exemplary pro-Europeans. But there are many echoes of Brexit in Catalonia. Instead of Brussels, it is Madrid the nationalists accuse of stealing Catalans’ money. They argue that independence would be quick and easy. “The great growth in support for independence from 2012 was the first manifestation of populism in Spain,” says Javier Cercas, a writer who lives in Barcelona.

Mr Puigdemont insists that blocking the referendum “would be bad news for democracy”. He is prepared to negotiate its timing. But he adds: “We won’t easily renounce it. I think we’ve earned the right to be heard.” Some in Barcelona believe the Generalitat’s leaders are searching for a dignified way to back down. Mr Puigdemont talks also of “constituent” elections to found a new state. But his party, clouded by corruption, may suffer. The Catalan variant of Spain’s left-wing Podemos, which already runs Barcelona’s city government and which is forming a new, broader, party, is likely to gain ground. It wants Catalonia to form part of a “plurinational” Spain, a cleverly vague formula.

“Is being part of Spain a problem in the daily life of Catalans?” asks Inés Arrimadas of Ciudadanos, an anti-nationalist party that leads the opposition in the Catalan parliament. “For us the problems of Catalonia are unemployment, poverty and corruption.” The longer the deadlock lasts, the harder Mr Puigdemont may find it to persuade Catalans otherwise.