MADRID - Gibraltar on Friday accused Spain of a "gross violation of British sovereignty" after two customs officials entered the British overseas territory during an anti-smuggling operation.

Early on Thursday, two Spanish customs agents were injured after rocks were thrown at them on a Gibraltar beach. Their small boat had lost power while chasing suspected tobacco smugglers, according to Spanish media reports.

In a video of the incident on Spanish daily El Pais' website, the smugglers are seen shouting "This is Gibraltar. This is not your job!"

Other videos on social media appear to show shots fired during the altercation, but it is not clear who fired them.

In a statement on Friday, Gibraltar's Chief Minister Fabian Picardo said: "The evidence surrounding this incident discloses a gross violation of British sovereignty and, potentially, the most serious and dangerous incident for many years".

He said Gibraltar needed to investigate the facts before deciding on what diplomatic response to take, but added "the events indicate that the actions by the Spanish officials are intolerable".

The governments of Gibraltar and the United Kingdom consider that the events "will require careful consideration as to the nature and level of diplomatic response," the Gibraltar government statement said.

Should it be confirmed that Spanish officials discharged their weapons in Gibraltar, this would be "a very serious breach of the law as well as being reckless and dangerous", it added.

Spain's foreign ministry on Friday condemned the attack on the customs agents, who had suffered "serious injuries" and said it "categorically rejects the terms" of the statement issued by Gibraltar, "as well as the claims of alleged British sovereignty over the territory and waters of Gibraltar contained within it".

The incident comes as Britain and Gibraltar seek to negotiate a treaty to settle Gibraltar's post-Brexit status and how to police the border with Spain.

This has been a point of contention since Britain's 2016 vote to leave the European Union. The peninsula was excluded from the exit deal reached between Britain and the EU.

In mid January, Spain's Foreign Affairs Minister Jose Manuel Albares told Reuters Madrid and London were "very close to a deal" on the issue.

Spain ceded the rocky outpost at the mouth of the Mediterranean Sea to Britain in 1713 but has long called for it to be returned. In 2002, 99% of voters in Gibraltar rejected the idea of Britain sharing sovereignty with Spain.

(Reporting by Jessica Jones; editing by Jonathan Oatis and Sandra Maler)