By Steve Kingstone
BBC News, Madrid
The Spanish flag is similar in colour to signal Flag No1, used in the exercise
The UK has apologised to Spain after the Royal Navy used a buoy with the Spanish colours for target practice.
The exercise took place off the coast of Gibraltar earlier this week. The UK ambassador was summoned to the foreign ministry in Madrid to explain.
According to local reports, the navy hastily removed the buoy, which had a red-and-yellow marker, when approached by a Spanish police launch on Tuesday.
Ambassador Giles Paxman conceded it was insensitive and an error of judgement.
While acknowledging that the target had appeared "similar" to the Spanish flag, he insisted that was not what it was supposed to represent.
And he assured his hosts there would be no repetition of the incident.
Later the UK Ministry of Defence clarified that the colours were those of a maritime signal flag used by Nato.
"HMS Scimitar was using Flag No1 during gunnery practice - not the Spanish national flag," a spokesperson said.
"Flag No1 is traditionally used on gunnery targets due to its high visibility - however, we recognise its similarity to the Spanish national flag and will use an alternative marker during gunnery practice in this area in the future."
Gibraltar remains the lingering source of tension in an otherwise good relationship between the UK and Spain.
The UK claims a radius of three nautical miles around the Rock of Gibraltar as British territorial waters.
Spain disputes this, and in recent months there have been bad-tempered verbal exchanges between the Royal Navy and the Spanish police.
Spain's main opposition Popular Party has urged the government to demand what it calls the "respect that Spain deserves".