Martin rode the final sixty kilometres of the mountainous 170km stage from Gerardmer alone as he secured Germany's fifth stage win of the race - and a second for Omega Pharma-Quick Step since the shock early withdrawal of Britain's Mark Cavendish.
Lotto-Belisol's Gallopin finished in a select chasing group 2:45 down on Martin and five minutes ahead of the peloton. The result means Gallopin will now wear the maillot jaune on Bastille Day on Monday - the Frenchman now leading Astana's Nibali by 1:34 in the overall standings.
With Martin riding a large chunk of the stage alone - and Switzerland's Fabian Cancellara (Trek) sprinting to take second place on the stage - there was an uncanny resemblance to the legendary time trial battles of old between the two specialists of the discipline.
Indeed, Martin's previous victories in the Tour - in 2011 and 2013 - both came from individual time trials, and by dropping co-leader Alessandro De Marchi (Cannondale) at the foot of the penultimate climb of the day, Martin certainly set things up for what he does best.
The 29-year-old powerhouse - looking a leaner 75kg than previous years - gobbled up the Cat.1 climb of Le Markstein before crossing the sixth and final climb of the day, the Cat.3 Grand Ballon, with three minutes to play with over a chasing pack of 28 riders.
Behind him, Gallopin led the chase on the long 30km descent - not so much in pursuit of the stage win but in a bid to keep his dream of taking the yellow jersey alive. Once in the valley, Martin had managed to increase his lead to just over three minutes as he faced a 20km flat individual time trial to the finish.
"There's a big difference between a successful time trial and and a stage race win," Martin said. "In a road stage like that you know if you've won but in a time trial you have to wait right until the end before you can celebrate.
"Today I knew with five kilometres to go that even a puncture or a crash would not stop me from taking the win. The feeling was incredible."
The victory was extra special for Martin given the race's proximity with the German border - which ensured a large amount of home support for the triple world time trial champion. Martin's victory is a fifth for German after Marcel Kittel's early sprint triple and Andre Greipel's single scalp.
Martin's win in the mountains also saw the rider take over the polka dot jersey from France's Blel Kadri of Ag2R-La Mondiale. But while the host nation lost one key jersey, it gained another - and the most important of all - with Gallopin's leap onto the top of the general classification on the eve of the French national holiday of Bastille Day.
"It's unbelievable. My parents and family are here and this yellow jersey is just completely unimaginable," said 26-year-old Gallopin. "Tomorrow will be very hard but it will be extraordinary to wear the yellow jersey and I really have nothing to lose."
With Astana leading the pack home 7:46 down on Martin, other big winners of the day were Portugal's Tiago Machado (Trek) and Frenchman Pierre Rolland (Europcar) who both jumped into the top ten after starring in the main chasing group that came home 5:01 ahead of the peloton.
Machado is now third place on GC, 2:40 down on Gallopin, while Rolland moves one second above Alberto Contador into eighth place at 4:08.
TWENTY-EIGHT-MAN BREAK: Green jersey Peter Sagan (Cannondale) attacked from the outset but was reeled in before a large group featuring Thomas Voeckler (Europcar) and Joaquim Rodriguez (Katusha) edged ahead. The race came back together on the descent of the first of six climbs before Martin and De Marchi finally extricated themselves from the peloton.
For a long time the leading duo held just thirty seconds over a select chasing group of 28 riders - including Gallopin, Cancellara, Rolland and Rodriguez. Despite the size of the group and the climbing calibre of some of its components, Martin and De Marchi continued to nurture their lead before Martin made his decisive move on the penultimate climb.
After the stage, Martin claimed he had attacked with De Marchi to avoid the "silly games" that would come from riding in a select group trying to contest the win. The German admitted he had made an agreement with his Italian colleague in which De Marchi was allowed to sweep up all the mountain points.
But by crossing the first Cat.1 climb of the 2014 Tour in pole position - and then adding two points on the final Cat.3 climb - Martin inadvertently added the polka dot jersey to his eventual stage win. A job well done ahead of Germany's World Cup final against Argentina later in the day.
RIDE OF THE DAY: Perhaps enraged by the fact that this year's route contains but one individual time trial, Tony Martin (Omega Pharma-Quick Step) brought about to engineer his own solo race against the clock - and in doing so won both the stage and polka dot jersey.
DAY TO FORGET: Marcel Kittel and the other sprinters came home in the gruppetto more than 21 minutes down on the stage winner. The last rider to cross the line? Kevin Reza of Europcar - who for most of the day was spotted setting a ferocious pace for team-mate Rolland on the hills. The final 100km of racing must have been pretty painful for the peloton's only Parisian.
COMING UP: Monday's 161.5km stage from Mulhouse is without a doubt the hardest of the race so far and includes six climbs (three of which are first category) before the steep ramp up to La Planche des Belles Filles. This is where Chris Froome won when riding in support of Bradley Wiggins back in 2012. Tuesday's rest day will be very welcome after this real zinger of a finale in the Vosges.
PLAT DU JOUR: Dine out on a variety of Haute-Saone specialities, including duck breast with sour cherries, braised sweetbreads with morel mushrooms, haunch of roast boar with bilberries, doe tournedos, fried carp, or even local frogs (in the wet season).
STAGE IN A SENTENCE: A tale of two Tonys as Martin time trials to victory and polks dots and Gallopin seizes the race lead to set up a day in yellow on 14th July.
- Sports & Recreation
- Alessandro De Marchi
- Pierre Rolland