Twenty-nine people were arrested across northern Spain as police seized nine kilos of ketamine, nine kilos of hashish, and varying amounts of speed, cocaine, marijuana and methamphetamines.
"The drugs were going to be distributed in Pamplona during the San Fermin festival," police said in a statement.
"While each organisation operated independently, they were in contact with each other," it added.
The ketamine, a veterinary anaesthetic that in humans causes hallucinations, was smuggled from India hidden inside personal hygiene products transported by drug runners on flights that arrived in Madrid, police said.
Authorities also seized three guns, three vehicles, several knives, three vehicles and €65,000 ($89,000) in cash as part of the operation.
The nine-day San Fermin festival, which gets underway on Sunday in the northern city of Pamplona, draws hundreds of thousands of tourists each year.
The fiesta, immortalised in Ernest Hemingway's classic 1926 novel "The Sun Also Rises", features religious ceremonies in honour of San Fermin, the patron saint of Pamplona, as well as concerts and round-the-clock drinking.
But the highlight is a daily early morning bull run, during which crowds of daredevils test their bravery by running with six half-tonne fighting bulls through the city's cobbled streets to the bullring.