It means your first interpretation: that the best outcome for Spain would be if both events happen: Spain permits the referendum on Catalan independence and Catalonia rejects it.
The comma is not needed. It's there only for a subtle rhetorical reason: in speech, you would use rhythm and intonation to emphasize that this is a paradoxical statement. Normally, or naïvely, one thinks of holding a referendum only with the hope that it will pass. The author is saying to hope for both a referendum and that the people vote it down.
There is no ambiguity between the two interpretations, but the reasons are subtle.
The word "for" functions differently each time each time it occurs in the sentence. In "the best outcome for Spain", it means the best from Spain's perspective—as in "good for Spain" or "Eat some spinach, it's good for you." The second "for" has a completely different meaning: it just introduces a clause that describes a hypothesis. It's like "for" in these sentences:
It's not unusual for a central government to ignore the concerns of a remote province.
For a central government to ignore the concerns of a remote province is not unusual.
The clause started by for actually serves as a big noun. You could think of the original sentence like this:
The best outcome for Spain would be a referendum and a rejection.
I've written "a rejection" to stand for "for Catalan voters to reject independence."
To speak clearly of two separate best things for two parties, you need two verbs, each with its own subject, like this:
The best outcome for Spain would be to permit the referendum, and the best outcome for Catalan voters would be to reject it.
This makes the reader see the second "for" as a normal preposition, indicating a relationship between "best outcome" and "Catalan voters". You could elide all that if you put a comma after "Catalan voters", like this:
The best outcome for Spain would be to permit the referendum; for Catalan voters, to reject it.
This would yield your second interpretation. Notice the semicolon to indicate that these are two separate propositions.
Another clue to the meaning, though, is that normally you'd only see contrasting clauses with elision like that if the two outcomes were mutually incompatible and if the two parties were separate rather than overlapping, like this:
The best outcome for Madrid would be if gas prices rose; for Catalonia, if they stayed level.
Equivocal usage of "outcome"
Another subtle reason why the original sentence is not ambiguous is that "to permit the referendum" is something that Spain could do. Notice that this sentence doesn't seem to make sense:
The best outcome for Spain would be to permit the referendum.
That sounds like saying that the best outcome for me would be to bet on a horse. The outcome would be the result of the race: whether I win or lose the bet, not the bet itself.
The author has engaged in some clever, subtle rhetoric here, exploiting a real ambiguity. You can (and should) think of Spain's permitting the referendum as a possible outcome of the current conflict over whether to hold a referendum. But one normally thinks of a referendum as having an outcome, not being an outcome. So, the author has used "the outcome" equivocally: to refer to the referendum as an outcome and to refer to the outcome of the referendum, switching from one to the other where the comma occurs. The comma helps emphasize that switch.
Some rhetoricians might call this figure of speech a zeugma, some a syllepsis, some both, and some neither. (Notice how I just elided three repetitions of the verb.)
Beyond the grammar, the context provides one more clue that the first interpretation is the one intended. The full sentence says:
The best outcome for Spain would be to permit the referendum, and for Catalan voters to reject independence—as voters in Quebec and Scotland have done.
Quebec and Scotland also rejected referenda on independence in recent years. The author's main point is that if the central government lets the Catalonian people have a voice in independence, instead of using the judicial system to justify ignoring them, this would force the central government to negotiate with them in good faith. Hopefully then both parties would find a mutually pleasing solution to their conflicts.