The Scottish independence drive - now resuscitated by the prospect of Britain's departure from the EU - is highly controversial in Spain because of the secessionist movement in Catalonia.
As a result, Madrid has long been seen as an obstacle to an independent Scotland joining the EU after Brexit. But its foreign minister, Alfonso Dastis, threw that in doubt on Sunday.
"Initially, I don't think we would block it," he said in an interview published in El Pais.
However, he added Scotland would have to leave the EU with Britain, and "the rest we will see".
He also said Spain did not welcome fragmentation of the Europe.
"Having said that, if, in application of its laws, the outcome of that process is a division of the United Kingdom, any part of the United Kingdom that becomes a state and wants to join the EU will have to apply. And follow the steps that are stipulated," he said.
The comments come after a week in which the issue of Gibraltar, a British oversees territory on Spain's south coast, has stirred tensions between London and Madrid.
The EU has said that, following Brexit itself, no future EU-Britain pact that affects Gibraltar can be made without Madrid's approval.
Britain has reacted sharply, saying its support for the territory, ceded by Spain in 1713 and which wants to remain British, is "implacable".
Dastis refused talk about veto rights when it comes to Gibraltar but said he viewed the EU's stance very positively.
"When the United Kingdom leaves the EU, the EU partner is Spain, and in the case of Gibraltar the EU is therefore obliged to take the side of Spain," he said. "I do not think it's necessary to talk about vetoes".
Dastis said that Spain's stance to not bloc attempts by Scotland to join the EU had nothing to do with Catalonia, where a vehemently pro-independence local administration took power in 2015 and with whom tensions are high.
"In Scotland there was a referendum in accordance with the laws," he said, referring to the 2104 vote to remain in Britain. "In Spain it can not be in accordance with the Constitution. They (Scotland and Catalonia) are not comparable cases."
Catalonia has vowed to hold an official referendum on its potential split from Spain later this year.
Dastis said its stance to not bloc attempts by Scotland to join the EU had nothing to do with Catalonia. "In Scotland there was a referendum in accordance with the laws. In Spain it can not be in accordance with the Constitution. They are not comparable cases", Dastis said.
Regarding Brexit in general, Dastis said Spain preferred a "soft Brexit" - one in which Britain remained linked through such things as tech single market - though he doubted this would be possible.
However he said Spain wanted to have a close relationship with Britain.
"As close as possible to what we have now. If that is to be defined as Brexit soft I am not uncomfortable with that," he said.
(Reporting by Jesus Aguado, Editing by Jeremy Gaunt)
(Except for the headline, this story has not been edited by NDTV staff and is published from a syndicated feed.)