SPAIN has known tumultuous times: civil war in the 1930s, dictatorship until 1975, a failed coup in 1981, a financial and economic crash in 2008-13, and terrorism of the nationalist and jihadist sorts. Now it faces a constitutional crisis that threatens its unity. The Catalan government plans to hold a “binding” referendum on independence on October 1st. If a majority votes yes—regardless of the turnout—then Carles Puigdemont, the Catalan president, will unilaterally declare independence.

The Spanish constitutional court has declared the vote illegal, and the conservative government of Mariano Rajoy has taken control of the region’s finances to try to block the ballot. The Guardia Civil has raided Catalan government offices and a private delivery firm to seize posters and ballot papers, and arrested at least 12 officials. The Catalan government has called for “peaceful resistance”.

The crisis is snowballing into a serious threat to Spain’s democracy. Solving it sensitively matters to the rest of Europe. The precedent set in Catalonia will affect other would-be separatists, from Scotland to the Donbas region of Ukraine.

Catalonia enjoys a standard of living higher than the average in both Spain and the European Union and more self-government than almost any other region in Europe, including powers to protect the Catalan language. It is, to outward appearances, a lovely and successful place. Yet a majority of Catalans are unhappy with their lot, feeling that Spain takes too much of their money and fails to accord respect to their identity (see article). Mr Rajoy has been wrong to assume that time and economic recovery would cure Catalans’ discontent.

The Spanish constitution, adopted by referendum in 1978—and backed almost unanimously in Catalonia—proclaims the country’s “indissoluble unity”. It vests sovereignty in the Spanish people as a whole, not in the inhabitants of its constituent parts. The Catalan government claims the right to self-determination. But international law recognises this only in cases of colonialism, foreign invasion or gross discrimination and abuse of human rights. These arguably do apply to the Kurds, who are planning to hold a disputed referendum on secession from Iraq on September 25th (see article).

Catalonia, however, hardly counts as colonised, occupied or oppressed. Many Spaniards worry that its secession could swiftly be followed by that of the Basque country. If the rule of law is to mean anything, the constitution should be upheld. Mr Puigdemont should thus step back from his reckless referendum. Opponents are unlikely to turn out, so any yes vote he obtains will be questionable, not just legally but politically. That said, by playing cat-and-mouse with ballot boxes Mr Rajoy has needlessly given Mr Puigdemont a propaganda victory. A big majority of Mr Rajoy’s voters in the rest of Spain support him in part because he refuses to yield to Catalan nationalism. But something important is wrong in Spain, and it is his duty to try to fix it.

Democracy requires consent as well as the rule of law. Constitutional change, especially the right to break away, should be difficult—but not impossible. In Scotland and Quebec, allowing people to have a say did not lead to breakaway. Mr Rajoy should be less defensive: he should now seek to negotiate a new settlement with Catalonia, while also offering to rewrite the constitution to allow referendums on secession, but only with a clear majority on a high turnout.

Damage to Catalonia

Many Catalans want the right to decide, but polls suggest that only around 40% want independence. Most would probably be satisfied with a new deal that gave them clearer powers, let them keep more of their money and symbolically recognised their sense of nationhood. The tragedy is that neither Mr Puigdemont nor Mr Rajoy seems interested in putting such an offer on the table.