Last summer, when Pedro Sanchez took over as Prime Minister of Spain after Mariano Rajoy was driven out of office in a finance scandal, Sanchez inhereted a rather large headache. The province of Catalan had declared its intention to seek independence and was only brought back in check after some of their leaders were either imprisoned or fled into exile. There were still other Catalonian elected officials in the country, however, and they were charged with a variety of offenses including treason.

The courtroom drama surrounding those cases has been dragging on for more than fifteen months, but now it’s drawing to a close. The nation’s highest court has rejected all appeals and sentenced a group of these officials to serious prison time.

Spain’s Supreme Court on Monday sentenced nine separatist leaders from Catalonia to between nine and 13 years in prison for sedition over their role in a failed independence bid, triggering protests across the region. Three other defendants who were also on trial for their involvement in the October 2017 referendum held in spite of a ban and a short-lived independence declaration, were found guilty only of disobedience and not sentenced to prison. All defendants were acquitted of the gravest charge, rebellion, but leading separatists were quick to condemn the court’s decision and the jailed men sent out messages of defiance, urging people to take to the streets.

Carles Puigdemont, the exiled Catalonian official who was once (briefly) the president of a nearly independent Catalonia, declared the sentences an outrage and called on his people to take to the streets in protest. They complied in large numbers, once again throwing Spain back into the spotlight with a potential revolution on their hands. In Barcelona, people were blocking roadways and chanting “We’ll do it again.” This is a reference to demands for another Catalonian independence referendum.

This was always the danger the Spanish government faced. They couldn’t afford to appear weak and simply ignore the fact that the breakaway province had attempted to secede from their nation. But at the same time, if they pushed back too hard and punished the Catalan leaders too severely, they risked yet another rebellion that could edge toward an actual civil war. Sending all of the former officials to prison for more than a decade doesn’t sound like much of a middle ground and the results should have been predictable.

Spain can’t afford to let Catalonia secede because it’s one of the richest and most productive regions in Spain. Without them, the economy would probably collapse. (Not that it’s been doing all that great lately anyway.) But the Catalonians see themselves as a distinct people, separate from the Spanish and even having their own language. The separatists get no support from the European Union, however, since the EU mostly just wants to avoid trouble and maintain the status quo.

Prime Minister Sanchez has a problem on his hands. Now he has to decide how hard to crack down on the protesters and how to respond if the Catalonian provincial government moves to schedule another independence referendum. And declaring martial law in the province and locking up massive numbers of people likely won’t be a viable option this time.