The 26-year-old escaped from a depleted peloton on a fast descent in the last 10km of the 187.5km run from Besancon to Oyonnax.
Although he was caught by a trio of chasers, he attacked them in the final 3km and held on for victory ahead of John Degenkolb and Matteo Trentin.
Italian Vincenzo Nibali finished safely in the chasing pack and held onto the leader's yellow jersey.
Richie Porte remains second at 2min 23sec with Alejandro Valverde third at 2:47.
Following Tuesday's rest day it was a hilly challenge for the remaining 179 riders in the peloton.
But for one in particular it seemed too much.
American Andrew Talansky woke up with a bad back and lost touch with the peloton in the first half of the race.
At one point he climbed off his bike and seemed to have quit but after a few minutes talking to his team, he got back in the saddle and carried on, in floods of tears, facing a race against time to finish inside the cut-off point.
Up front a three-man breakaway that lasted more than 100km was gobbled up before a succession of other attacks on a series of short climbs served only to increase the peloton's speed and reduce its numbers.
But Gallopin picked the ideal moment to attack and although he seemed to have come up short, he went again and this time made it stick.
Having worn yellow already in this Tour, he now added his first stage victory in the Grand Boucle and the second by a Frenchman this year.