RadioShack-Leopard rider Gallopin, 25, unexpectedly attacked close to the summit of the final Cat.2 Alto Arkale climb out of a leading group of 10 riders.
Six of the group gave chase but could not close the gap and Alejandro Valverde (Movistar) pipped Roman Kreuziger (Saxo-Tinkoff) to finish second.
The peloton was split on the penultimate Cat.1 Jaizkibel climb, with Kreuziger then breaking clear only to be caught by seven other riders on the descent.
That group of eight became 10, with two others bridging the gap to the main pack, on the flat section between the two climbs.
When Gallopin jumped it took the others by surprise, with pre-race favourite Valverde, Kreuziger, Nicolas Roche (Saxo-Tinkoff) and Euskaltel-Euskadi pair Mikel Landa and Mikel Nieve eventually taking off after him.
Gallopin - whose lead had reached a maximum of 25 seconds - led by 16 seconds with 2km remaining and so the chasers backed off to prepare for a sprint for the podium places.
That allowed him to coast to victory on the 232km one-day race in northern Spain by a 28s margin.
Nieve was fourth ahead of Roche and Landa.
- Sports & Recreation
- Roman Kreuziger
- Alejandro Valverde