Just two months ago, Spanish Prime Minister Mariano Rajoy was in the ignominious position of having to appear on a witness stand in a Madrid courtroom and face a grilling from a judge over what he knew about a long-standing corruption case that has sideswiped his ruling People’s Party.

Rajoy became the first sitting Spanish prime minister to have to testify in a criminal case, and while he is not facing any charges of criminal wrongdoing himself — the case dates back to between 1990 and 1993 when he was the party’s vice-secretary-general — it is emblematic of the corruption allegations that have been levelled at his party over the past six years. Rajoy has been in power since 2011.

He’s a man not known for his colour or sense of humour, and the court appearance made for juicy fodder for political commentators and comedians alike. For Rajoy, it was just a legal formality, but one that needed his personal attention. Another legal matter, however, is also receiving his personal direction, with the aggravating Catalan referendum planned for this Sunday also needing legal clarification.

Under Spain’s constitution, there is no clause that allows for the break-up of the nation, nor for the succession of any constituent part.

Simply put, any vote by any region to seek independence is illegal.

Once before, just days before the Catalan region staged a referendum in November 2014, the Spanish Constitutional Court ruled the vote on independence to be illegal. The referendum went ahead anyway, and 80 per cent of those who did cast ballots chose the independence option for Catalonia. Rajoy was roundly criticised then for not taking the Catalans to court much earlier.

Rajoy, however, followed up on that ruling and pushed for charges to be laid against the organisers of the 2014 plebiscite. Artur Mas, then the president of the Catalan parliament, along with former vice-president Joana Ortega and former Catalan education minister Irene Rigau, were convicted by the Catalan high court in early February of this year for defying the Constitutional Court ruling that declared the plebiscite illegal. Mas was fined €36,500 (Dh144,000) and, significantly, banned from holding public for two years. Ortega was handed a 21-month ban from office and a €30,000 fine, while Rigau can’t hold office for 18 months and was ordered to pay €20,000.

This time around, Rajoy was way more proactive, seeking a ruling from the court again on the illegitimacy of Sunday’s vote. That ruling was issued in the spring. To no one’s surprise, the Constitutional Court ruled Sunday’s vote to be illegal. This time around though, Rajoy has upped the ante, ordering stern action against the separatists.

Last week, Spain’s Guardia Civil — the national police force — arrested 14 Catalan officials who were organising the vote, and seized ballot papers and other printed materials necessary to hold the referendum for the region’s 7 million citizens. Rajoy’s government has also cancelled leave for more than 3,000 Guardia officers and has beefed up their presence in Barcelona and the Catalan region in the run-up to Sunday’s vote.

The separatist government of Catalan Premier Carles Puigdemont is calling Rajoy’s measures high-handed and likens the government’s actions to the dark days of the Franco regime.

But the reality is that the referendum is illegal, has no moral weight, and Rajoy is acting within the letter and spirit of the law to uphold the Spanish Constitution.

Puigdemont and another separatist politician, Carme Focadell have already been warned they face charges for pressing ahead with the new October 1 vote — and given that Rajoy has shown himself to be unafraid of using the legal means open to him to thwart the referendum so far, there’s every reason to believe that the two will find themselves before a Spanish magistrate sooner rather than later.

Thousands of Catalans have taken to the streets of Barcelona in protest at Rajoy’s actions. He has made it clear, however, that any mayor that allows any municipal building or resource to be used in Sunday’s vote will face sanctions. Similarly, any school or other institution that is used as a voting place will also face sanctions.

So will Sunday’s vote go ahead?

Yes, there will be a plebiscite of sorts, but only the most ardent Catalonians will cast ballots. Even then, given the weight of Spanish law and authorities in opposing the referendum, it will likely be a highly disorganised and certainly discredited affair. And regardless of the process or its legitimacy and obvious lack thereof, Puigdemont will call the inevitable ‘Yes’ result as a mandate for an independent Catalan state. It is no such thing, and Rajoy has used every legal measure available to him to ensure it is nothing but a charade.

The danger is that the most ardent Catalonians may regard the entire episode as Madrid’s refusal to recognise a democratic process and accuse the central government of ignoring the legitimacy of Catalan history and heritage.

That’s simply not the case.

Catalonia is one of 17 regions that make up Spain, and while it has a distinct heritage and history, it is not unique in that regard. The Spanish Canary islands too, for example, have an independence movement, are linguistically distinct, are a distinct geographical entity and have the ability to sustain themselves economically if freed from Madrid’s authority. But the Canarians are playing a long game, pressing for constitutional change first.

Given Rajoy’s actions surrounding the first Catalan referendum, and his determination to ensure that Sunday’s vote amounts to nothing more than a political farce, the Catalan leadership is simply playing into Madrid’s hands by going ahead with Sunday’s vote. It’s too late now to put the independence genie back into the bottle — and too late to save face and prevent Catalan’s case for independence from being punted into obscurity for now.

And Rajoy’s popularity now? A majority of Spaniards like the way he’s handling the issue of Catalan independence. So much so that he might feel emboldened enough to suspend the Catalan regional assembly — or at least remove its powers to collect revenues.