Cavagna went on the attack with Alex Hoehn of the USA National Team but the Frenchman distanced him and pushed on alone with 75km of the 208km stage still to go.
Hoehn was rewarded for his efforts at the end of the day with the 'king of the mountains' jersey, while Cavagna rode hard to ensure he won alone. He also finished a huge 7:11 margin ahead of chasers Ben King (Dimension Data) and Simon Geschke (CCC Team), who had caught and passed Hoehn before the finish.
Cavagna struggled on descents to the finish after going deep with his solo attack but was overjoyed to win.
"It was really hard. Not on the climb, but on the downhill I was a little bit scared because it was really tricky, although I tried not to take too many risks, and I did it," a delighted Cavagna said.
Hoehn was caught by what was left of the bunch, which included all of the main favourites, including race leader Tejay van Garderen (EF Education First) who retained his six-second lead over Gianni Moscon (Team Ineos)
Watch how it all unfolded in the highlights video above.