Cameron's assurances came despite claims from lawmakers that Spain was acting like "the Zimbabwe of Robert Mugabe" in the latest in a string of bad-tempered confrontations between London and Madrid.
"It's an extremely serious action that took place," Cameron told parliament.
Cameron said the incident was a "breach of the principle of state immunity and the principles underlying the Vienna Convention on Diplomatic Relations."
"We asked the Spanish authorities to investigate urgently and they have done that," he added.
More From This Section
Europe minister David Lidington later told lawmakers that Spain had blamed a junior official manning the border on Friday.
Lidington said he was now keen to de-escalate tensions.
But many lawmakers expressed disbelief at Spain's response, noting the bag incident was only the latest of many provocations in the British territory on Spain's southern tip that have tested ties between London and Madrid.
"This is the first time that an EU state or NATO ally has opened a UK diplomatic bag, violating the 1961 Vienna Convention," said Nigel Evans, an MP from Cameron's Conservative party.
Evans had called an urgent question in the House of Commons to discuss the issue and demanded of Spain, "Hands off the Rock," referring to territory.
The British embassy in Madrid lodged a formal protest with the Spanish government on Monday, and received the response yesterday, Lidington said.
He said Madrid explained "that this was an error at a junior operational level at the crossing point between Gibraltar and Spain, and that the more senior Spanish official present put a stop to that interference with our official correspondence as soon as he realised what it was that was happening."