The Foreign Office has demanded an explanation after a British diplomatic bag was opened and searched by Spanish Guardia Civil officers on the border with Gibraltar.

The incident, which took place on Friday, was described by a Foreign Office spokesman as a "serious infringement" of international diplomatic protocols.

"Diplomatic bags are inviolable," the spokesman said.

Downing Street said a diplomatic message known as a "note verbale" had been sent to authorities in Madrid to make clear formally the action was "unacceptable".

Prime Minister David Cameron's official spokesman said: "The key point for the Spanish government to understand is the unacceptability of this kind of action and for them to desist."

The incident was reported by the Gibraltar Chronicle which said it occurred when a courier was taking the bag across the border from Gibraltar into Spain.

Diplomatic bags and their diplomatic missions abroad are protected by the 1961 Vienna Convention on Diplomatic Relations.

A Foreign Office spokesman said: "There are long-established and internationally-accepted articles concerning official correspondence and the diplomatic bag to which the FCO adheres.

"We have asked the Spanish authorities to investigate what occurred and take action to ensure it does not happen again. There is no justification for this infringement of the UK's rights under the Vienna Convention.

"Official correspondence and diplomatic bags are inviolable."