The SNP has called on Spain to allow a Scottish-style independence referendum in Catalonia.

In an unprecedented intervention, the party warned Madrid that attempts to block a Catalan vote were "anti-democratic, anti-European and potentially explosive".

The warning shot from the SNP - which has stayed out of Spanish constitutional politics in recent years - came as polls suggested an alliance of Catalan pro-independence parties were on the cusp of an historic victory.

Banned from holding a Scottish-style legally binding referendum, Catalonia's ruling independentistas have turned next weekend's elections to the nation's parliament in to a proxy plebiscite.

At a glance: the forces fighting Catalunya's proxy indyref

This puts them on a collision course with Madrid's ruling conservatives, who, backed by Spain's constitutional court, insist Catalonia is not a nation and has no right to secede.

But the SNP's main Europe spokesman, Alyn Smith MEP, warned Madrid that their stance ran contrary to the democratic traditions of the European Union and could spell disaster.

Smith said: "Catalonia is a nation, and has a right to choose. That is absolutely clear. The alternative is simply anti-democratic, anti-European, and potentially explosive."

Opinion: Alyn Smith MEP: Catalunya is a nation and has the right to choose

Catalan elections are on Sunday, September 27. Two big groupings, Junts pel Sí or Together for Yes, and the radical left CUP, say they are treating the vote as a referendum.

The latest poll signalled that they would take an absolute majority of seats in the Catalan parliament and 49.9 per cent of the popular vote.

Their opponents, including Conservatives, Greens, ultra-unionists and Socialists, insist the parliamentary votes are not a defacto indyref. Parties opposed to independence, however, are split on whether a Scottish-style referendum should be allowed.

Latest poll: Independence forces heading for historic victory in Catalunya's proxy indyref

Natalie McGarry, the SNP MP for Glasgow East and a Catalan watcher, believes a Scottish solution could end the impasse: "If pro-independence parties in Catalonia win a mandate in the coming elections then the Spanish government must respect this.

"It would be remiss of a party that has just enjoyed a democratic referendum not to stand alongside the Catalan people in support their right of self-determination.

"We are not presupposing what choice the people of Catalonia will make. That is entirely theirs."

Catalan independence leaders, including current president Artur Mas, have not always enjoyed vociferous public backing from the SNP.

Scottish nationalists stayed out of Catalan politics during the independence referendum in the hope that Spanish unionists would return the favour.

However, at a crucial stage in last year's campaign current Spanish prime minister Mariano Rajoy threatened to veto Scottish membership of the EU.

This month UK Prime Minister David Cameron mirrored Rajoy's remarks of 2014, suggesting an independence Catalonia would also be ejected from the bloc if it attempted to become independent.

Scottish Tories, however, have been uncomfortable with rhetoric coming out of Madrid, including a veiled threat of military action from Spain's defence minister, former arms dealer Pedro Morenés.

Conservative MEP Ian Duncan backed a Scottish-style democratic solution for Catalonia.

He said: 'This is a matter for the people of Catalonia. Any threats, however subtle, which imply a military reaction to citizens exercising their democratic right must be opposed in the strongest possible terms.

"The Edinburgh Agreement is a shining illustration of what can be achieved when two Governments come together in good faith, and I hope this example is followed in Catalonia."

Duncan's views were echoed by a spokeswoman for the Scottish Liberal Democrats. She said: "This is a decision for the people of Catalonia to make.

"Scotland is an example where the democratic process was fair, legal and decisive. Both the Spanish and Catalan governments must work to ensure, whatever the outcome, that decisions around the constitution follow the same high standards."

The Scottish Greens also backed a free vote in Catalonia. Their Catalan allies are ambivalent about independence itself - but believe the nation has a right to decide.

Ross Greer, the party’s spokesman on Europe, said: "It is with a sad sense of deja vu that we see the arguments deployed against Catalan independence by the same political establishment who used them in Scotland last year.

"David Cameron, Mariano Rajoy and Angela Merkel know that the European Union cannot afford to lose a Catalonia committed to the European project, just as it could not afford to lose Scotland.

"It is not for us to say which way Catalans should vote but like our sister Green party in Catalonia, we firmly support the right of self-determination for all peoples."

Scottish Labour failed to respond to Sunday Herald requests for comment on the issue. Its sister party in Spain, the socialist PSC, opposes independence but is open to a plebiscite.

Catalonia attempted to hold a referendum shortly after Scotland last year. This was blocked by the Spanish Constitutional Court.

Opinion in the country - fully part of the Spanish state since 1714 - remains as divided as in Scotland.

Polls suggest that Ciutadans, a relatively new party set up on an "anti-nationalist" ultra-unionist ticket, may become the second biggest force in Catalan politics.