Josep Borrell, the acting Foreign Minister, ordered the Spanish consul in Edinburgh to be immediately removed from his post last week,
It follows the publication of a letter by the consul, Miguel Ángel Vecino, which said that Spain would not veto an independent Scotland's entry into the European Union.
The Spanish government explained the sacking by saying that Vecino had "acted beyond his responsibility", in voicing political options on the affairs of another country.
The subject of any future independent Scotland is a delicate subject not just in the United Kingdom but also in Spain, where the government is keen not to set a precedent of newly founded states joining the EU, as Catalan separatists wish to do the same.
In a letter to The National, an Edinburgh publication, the Spanish consul had said that the minister, Borrell, had confirmed that Spain would not veto a Scottish application to join the EU. The article was welcomed by the Scottish first minister, Nicola Sturgeon.
However the ministry for Foreign Affairs quickly clarified the Spanish government's position, saying it wasn't a consul's job to speak about policy.
Vecino defended himself, saying that he had written it in a private capacity and that he would take it up with the ministry, although this came too late to save his job.