The Royal Navy was forced to fire flares at a Spanish research vessel after it strayed into British Gibraltar territorial waters.
HMS Sabre gave the warning to Angeles Alvarino after attempts to contact it by radio failed.
The research vessel, which is investigating the geological risks to the seabed, left British waters after the flares were fired.
A Ministry of Defence spokesman said: "The Royal Navy challenges all unlawful maritime incursions into British Gibraltar territorial waters (BGTW).
"We back this up by making formal diplomatic protests to the Spanish government."
Gibraltar chief minister Fabian Picardo said he had been in contact with Commander of British Forces, Commodore Mike Walliker.
He said: "I have discussed all the tactical decisions taken and am satisfied that they have been designed to demonstrate untrammelled sovereignty jurisdiction and control over BGTW.
"I congratulate the Royal Navy for the work they have undertaken so far in very challenging circumstances in light of the reckless disregard for safety displayed by the official Spanish vessels involved.
"Diplomatic and political action must now support the excellent work undertaken by the navy personnel with limited resources."