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.
"We have now received an explanation from the Spanish. We are reassured this will not happen again."
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.
He added: "The last time anything like this happened was 13 years ago by the Zimbabwe of Robert Mugabe — not the best of company to be associated with."
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 late Tuesday, 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 realized what it was that was happening."
The incident came just a week after the Spanish ambassador to London was hauled into explain the presence of a state research vessel off Gibraltar's territorial waters.
A diplomatic source in Spain had previously told news agency AFP that the bags searched last week "did not fulfill the requirements" to be considered as diplomatic.
But Lidington said they were "clearly marked" as containing official correspondence and communications.
He added: "We are maintaining strong pressure on the Spanish government to de-escalate current tensions and to work with us to manage our differences through diplomatic and political roots.
"A major escalation could harm all parties, not least the many thousands of Spanish families who benefit directly or indirectly from the economic prosperity of Gibraltar."