Malaga police interviewed the two Royal Navy commandos on May 18 and Malaga sub-prefect Hilario Lopez Luna confirmed at a news conference a story in local daily Sur that an investigation was under way into the incident.
British forces spokeswoman in Gibraltar captain Katherine Prudhoe confirmed the duo's detention.
"When they were being followed in Malaga, they were looking for a place to stay overnight as they could not make it to Gibraltar that day," Prudhoe said.
Sur reported that the pair could have been connected to the presence in the middle of last month at Gibraltar of nuclear submarine HMS Trenchant, which spent five days in port.
But Prudhoe said that was not the case.
"The equipment is unrelated to the nuclear submarine HMS Trenchant. It was for an exercise here," she said.
Sur reported that Malaga police detained the two men in the early hours suspecting they might be trafficking drugs as the area is used by traffickers to smuggle narcotics to southern Spain from north Africa.
Spanish media reports named the men as Andrew William Harry Smith, 26, and Wayne Gordon Athey, 28. The pair spent four hours being interviewed by police and were then released after British military authorities confirmed their identity.
Material found in their Gibraltar-registered vehicle included outboard motors, an inflatable boat, diving equipment and strongboxes bearing Royal Navy insignia.
According to Sur, Royal Navy commanders in Gibraltar confirmed to Spanish authorities the men were on a secret mission to transport material from Britain to Gibraltar in advance of tactical manoeuvres scheduled for May 21 on a nuclear submarine.
The navy said the material was unusually being transported by road rather than air or sea given the current large presence in Iraq of British naval and airforce personnel.
Gibraltar, a British possession for three centuries, is a constant source of irritation for Spain, which lays claim to the territory on the southern Spanish coast.
Recent years have seen a number of rows over the presence of British nuclear-powered submarines visiting the port.
Four years ago former Spanish prime minister Jose Maria Aznar urged Britain to take into British waters its HMS Tireless nuclear submarine after it docked in Gibraltar for repairs to a leak near its nuclear reactor and following problems with its reactor cooling system.
That and other submarine visits led to political and public protests in neighbouring Spanish communities.