On the face of it, Spain’s national election on Sunday followed the familiar European script: highly polarized campaign, the emergence of a far-right party, no party with the parliamentary seats to form a government on its own. But it came with a distinctly Spanish twist.

The difference was that the catalyst for most of the turmoil was not immigration, globalization or social change, but Catalonia and its drive for independence. Nationalist sentiment in Spain has been especially strong since separatist leaders in Catalonia held an independence referendum in October 2017 that Spanish courts declared unconstitutional. In the ensuing crackdown, several Catalan leaders were arrested or fled the country. Currently, 12 are on trial on charges of sedition and rebellion.

Right wing parties bludgeoned Prime Minister Pedro Sánchez, branding him a traitor for including Catalan parties in his coalition and trying to negotiate with separatist politicians. In fact, the talks went nowhere, and it was the Catalan parties that pulled the plug on his Socialist government in February.

The fury on the right actually seemed to benefit Mr. Sánchez, who recognized that voters do not fully share the anti-separatist zeal of the politicians and sensed a danger in the rise of the far right. Though the far-right Vox became the first party of its kind to enter the national parliament since Spain’s transition to democracy decades ago, it also siphoned votes and seats from the mainstream conservative Popular Party, which won 66 seats compared to the 137 seats it won in 2016, and allowed Mr. Sánchez to campaign against “the reactionaries and the authoritarians.”