Fabio Aru (Astana) attacked the Tour de France overall classification contenders on the stage five summit finish to La Planche des Belles Filles to take victory, while Chris Froome (Team Sky) took the overall lead of the race.
The Italian champion made a move from a reduced group of overall contenders with 2.4km to go on the steep slopes of the final climb, and quickly put in a gap of 11 seconds to those behind.
Aru continued to look strong on the way up the climb, where his compatriot Vincenzo Nibali won in 2014 for Astana, even when Chris Froome instigated a move with 1.6km to go.
The defending champion was unable to drop all of his rivals, with Richie Porte (BMC), Daniel Martin (Quick-Step) and Romain Bardet (Ag2r La Mondiale) all able to hold him.
That move did little to eat into Aru's advantage though as he continued strongly up the climb, and things slowed down as Froome looked for the likes of Porte to take the front in pursuit of Aru.
That allowed the Astana man to push on towards victory, and he crossed the line in celebration of his first stage victory at the Tour de France.
The slowing of the Froome group behind allowed the likes of Simon Yates (Orica-Scott) and other dropped riders to close the gap, with Dan Martin able to make a late attack in the final hundred metres to take second place and six bonus seconds.
Froome was able to then cross the line in third to take six seconds, with Porte settling for fourth.
That meant that Froome took over the race lead from his team-mate Thomas who moves to second, with Aru in third and Dan Martin now fourth.
How it happened
Jan Bakelants (Ag2r La Mondiale), Mickael Delage (FDJ), Edvald Boasson Hagen (Dimension Data), Dylan van Baarle (Cannonale-Drapac), Pierre-Luc Perichon (Fortuneo-Oscaro), Thomas Voeckler (Direct Energie), Philippe Gilbert (Quick-Step Floors) and Thomas De Gendt (Lotto Soudal), formed the day's breakaway from drop of the flag, establishing a maximum gap of 3-24.
They were never allowed to get too far away and were forced to work hard with the peloton keeping the pace extremely high in the opening part of the race, with Porte's BMC team doing a huge amount of work all day.
Bakelants helped reduce the breakaway group to six with an attack on the only other categorised climb of the day with around 50km to go. De Gendt and Delage were both unable to keep the pace and dropped back to the chasing bunch.
After the gap closed down to just over a minute, the break regrouped and managed to have 2-14 with 20km to go.
But that continued to fall the closer the race got to the final climb of La Planche des Belles Filles, and Gilbert attacked his breakaway companions on an incline with 13km to go.
While all riders made chase, only one was able to get to him and work with him out front; his compatriot Jan Bakelants.
But Sky were now working on the front of the bunch in aid of Froome, and as the Belgian pair out front hit the early slopes of the climb with 50 seconds, it looked like the bunch had timed the catch perfectly.
The break was then inevitably caught with 5km remaining, with Sky's Michal Kwiatkowski making a huge effort to drag his team up the climb.
It then came down to the GC contenders as more and more riders dropped off the back, with Aru able to make the decisive attack for victory.
The Tour de France continues on Thursday with stage six, a 216km route from Vesoul to Troyes that should suit the sprinters.
Tour de France 2017, stage five: Vittel - La Planche des Belles Filles (160.5km)
1 Fabio Aru (Ita) Astana Pro Team, in 3-44-06
2 Daniel Martin (Irl) Quick-Step Floors, at 16s
3 Christopher Froome (GBr) Team Sky, at 20s
4 Richie Porte (Aus) BMC Racing Team, at 20s
5 Romain Bardet (Fra) AG2R La Mondiale, at 24s
6 Simon Yates (GBr) Orica-Scott, at 26s
7 Rigoberto Uran (Col) Cannondale-Drapac, st
8 Alberto Contador (Esp) Trek-Segafredo, st
9 Nairo Quintana (Col) Movistar Team, at 34s
10 Geraint Thomas (GBr) Team Sky, at 40s
General classification after stage five
1 Christopher Froome (GBr) Team Sky, in 18-38-59
2 Geraint Thomas (GBr) Team Sky, at 12s
3 Fabio Aru (Ita) Astana Pro Team, at 14s
4 Daniel Martin (Irl) Quick-Step Floors, at 25s
5 Richie Porte (Aus) BMC Racing, at 39s
6 Simon Yates (GBr) Orica-Scott, at 43s
7 Romain Bardet (Fra) Ag2r La Mondiale, at 47s
8 Alberto Contador (Esp) Trek-Segafredo, at 52s
9 Nairo Quintana (Col) Movistar Team, at 54s
10 Rafal Majka (Pol) Bora-Hansgrohe, at 1-01
Thank you for reading 5 articles this month* Join now for unlimited access
Enjoy your first month for just £1 / $1 / €1
*Read 5 free articles per month without a subscription
Join now for unlimited access
Try first month for just £1 / $1 / €1