Rennie claimed if there was ever independence the Spanish would handle Scotland over EU membership in the same way as it is treating Gibraltar over Brexit.
Guidelines for Brexit negotiations by the European Council state agreements between the EU and Britain on issues like trade will apply to the British territory only if it is agreed by Madrid.
Rennie said: “The situation with Gibraltar is just a taste of how an independent Scotland would be treated in any future negotiations. For the SNP to believe that Spain will simply bend over backwards and just waive Scotland into full EU or even Efta membership is delusional.
“The Gibraltar situation should be a hard lesson for the SNP that Spain will look after their own interest and that means making sure that nothing aids Catalonia’s bid for independence. Easy access for an independent Scotland into the EU would clearly be something the Spanish would not want.”
The warning came as shadow Brexit Secretary Sir Keir Starmer said the people of Gibraltar must not be used as a “bargaining chip”.
The government is attempting to reassure Gibraltar that the UK will stand up for the British overseas territory during the Brexit negotiations. But Gibraltar’s government has accused Spain of trying to use the UK’s decision to leave the EU to pursue its territorial claims to the Rock.
Starmer said on Twitter: “Spoke to Brexit Secretary David Davis this morning about vital need to protect sovereignty & interests of Gibraltar. Not a bargaining chip.”
A spokesman for Holyrood’s Brexit minister Michael Russell said: “Leading Spanish politicians have been clear they will not oppose an independent Scotland’s place in Europe.”