Police found the hashish, with an estimated street value of € 50 million ($65 million), when they searched a refrigerated truck carrying melons from the Moroccan port of Tangiers.
On its arrival in the southern Spanish port of Algeciras on April 27, police searched the Moroccan-registered truck.
"On opening it, they found melons were being carried in the first two pallets, as the driver stated," said a joint statement by the police and Spain's interior ministry.
"Then as the agents checked the rest of the cargo they discovered wooden boxes, which were open at the top, containing packs of hashish wrapped in sacking."
A total of 24 boxes were discovered containing 32.38 tonnes of hashish and the driver was arrested on suspicion of committing a crime against public health, police said.
The record for Spain dates to 1996 when 36 tonnes of hashish were seized in a boat in the country's southeast, leading to the arrest of 23 people.
But larger hauls have been recorded elsewhere, including notably in June 2008 when Afghan anti-narcotics police seized 237 tonnes of hashish.
Spain is the main gateway into Europe for hashish from neighbouring Morocco and the police regularly make large seizures. Last year, Spain intercepted a total of 325.5 tonnes of hashish, down 8.5 percent from the year before, the interior ministry said.