Gibraltar was drawn in the same Euro 2016 football tournament qualifying group as Spain - only to be moved to another for political reasons.
The blind draw in Nice, France, briefly saw the British overseas territory paired up with the current European and world champions in Group C.
But European football's governing body UEFA had already announced in December that Gibraltar and Spain would be kept apart amid continuing political tensions over the territory's sovereignty.
Gibraltar was drawn in the same Euro 2016 football tournament qualifying group as Spain - briefly
Gibraltar was switched to Group D, where they will face Scotland and the Republic of Ireland among others.
Gibraltar's Chief Minister, Fabian Picardo, tweeted:
The territory, which has a population of 29,000, became a full member of UEFA last year and will be competing in the qualifying round for the first time.
UEFA's executive committee announced that its newest member would be kept separate from Spain after a meeting in Bilbao in December.
General secretary Gianni Infantino was quoted as saying: "Gibraltar is a full member and will participate in the draw on February 23, but it will not play against Spain. That was one of the criteria that was decided."
Armenia and Azerbaijan, who went to war between 1992 and 1994 and still have territorial disputes, were also kept apart in the qualifying round for Euro 2012.
Gibraltar first applied for UEFA membership in 1999 but faced opposition from Spain, which sought to stop a precedent being set for Basque and Catalan national football teams.
It was accepted as UEFA's smallest full member by population at a congress held in London in May, with only Spain and Belarus opposed.
The territory's first official international was a 0-0 friendly draw against Slovakia held on November 19 at the Estadio Algarve in Portugal.
The Euro 2016 qualifying round, which runs from September 2014 to November 2015, will also see the overseas territory face Germany, Poland and Georgia.
Today's draw took place as three Royal Navy warships were set to dock in Gibraltar as the row between the UK and Spain over the Rock rumbled on.
HMS Westminster, HMS Brocklesby and HMS Daring were reportedly due to carry out patrols after a Spanish warship interrupted an elite forces training exercise last week.
A spokesman for Gibraltar told the Sun on Sunday: "Royal Navy ships are always welcome, no matter how long they stay."
England, meanwhile, were handed a straightforward qualifying campaign in Group E and will face Switzerland, Slovenia, Estonia, Lithuania and San Marino.
Wales have a shot at a play-off place or better in Group B, where they will face Bosnia-Herzegovina, Belgium, Israel, Cyprus and Andorra.
A Ministry of Defence spokesman said: "Royal Navy ships will continue to visit Gibraltar regularly in relation to operational and training activity, reflecting its utility as a permanent joint operating base."