Vincenzo Nibali (Astana) attacked on the final big climb of the day, further distanced his rivals on the decent and held them off on the final shorter ascent to the finish line.
There was then a tense wait for pink jersey Esteban Chaves (Orica-GreenEdge), but the Italian had done enough to win his second Giro d'Italia.
Stage 21 is the ceremonial ride into Turin, which is expected to end in a bunch sprint and have no impact on the overall classification.
Alejandro Valverde (Movistar) rallied towards the end to finish not far behind Nibali and move himself up the overall standings to third.
Steven Kruijswijk (LottoNL-Jumbo) could not stage a huge recovery and slipped further down the standings.
Nibali's ride was set-up by an attack from his teammate Michele Scarponi (Astana) with 17.6km to go. Chaves reacted first, and was also joined by Kruijswijk.
Others then came up when the paced slowed, including Rigoberto Uran (Cannondale), Bob Jungels (Etixx-Quick Step), Rafa Majka (Tinkoff) and Valverde.
With 12.2km to go, Nibali attacked the group in a hairpin. Chaves and Valverde were able to follow, but Kruijswijk was distanced.
Just 300 metres later, Chaves lost the wheel and Nibali started to pull away from the pink jersey. Valverde then attacked Chaves, who was at first able to ride back onto the Spaniard's wheel but looked to be struggling.
Nibali caught up with Tanel Kangert, who put in a huge turn for his team leader. Soon after, Uran caught up with Chaves and Valverde. National alliances came into play as Uran set the pace for Chaves.
That alliance only lasted as long as Chaves's legs and Uran rode away with Valverde when the Orica rider couldn't stay with them.
Chaves, who started the day 44 seconds ahead of Nibali, found himself 55 seconds behind at the summit of the second to last climb.
This gap only went out as Nibali, Valverde and Uran got away. The Kruijswijk group caught up with Chaves and they rode towards the finish together.
Earlier in the day, Mikel Nieve (Team Sky) put himself in the day's main break, and once again tried his luck with a solo attack. Ascending the huge Col de la Bonette, over in France, the Basque rider got his sponsor plenty of television time.
Back in the peloton, Orica-GreenEdge and Astana massed at the front to control the pace and keep their GC men safe. Before long Movistar came forward and upped the pace. At this point, Nieve had 84km to go and was 10-24 ahead of the main bunch.
Nieve held enough of a gap to get over the classified climbs first and in so doing looks set to win the KOM jersey overall.
Gianluca Brambilla (Etixx-Quick Step) managed to solo his way across to the lead group, which had caught Nieve on a descent with 46km of the stage remaining. At this point the group held 8-34 over the chasing pack.
No sooner had they gone through the intermediate sprint point than they were once again climbing, this time up the final first category climb of the race.
The group lost impetus when Visconti stopped coming through, apparently avoiding taking a turn as he was under instruction to wait for his team leader, Valverde.
Atapuma put in several attacks to keep the Nieve group off their wheels, but by now Dombrowski was also reluctant to go on the front.
Nieve's day seemed to be done when he couldn't keep the pace, meaning Kangert and Taaramäe were able to bridge to the Atapuma group.
By now it was all kicking off in the group of favourites, where the final GC of the 2016 Giro d'Italia was set.
Giro d'Italia 2016 stage 20, Guillestre to Sant’Anna di Vinadio, 134km
1. Rein Taaramae (Est) Katusha, at 4-22-43
2. Darmin Atapuma (Col) BMC, at 52s
3. Joe Dombrowski (USA) Cannondale, at 1-17
4. Mikel Nieve (Esp) Team Sky, at 4-12
5. Alexander Foliforov (Rus) Gazprom, at 4-36
6. Vincenzo Nibali (Ita) Astana, at 6-44
7. Alejandro Valverde (Esp) Movistar, at 6-57
8. Rigoberto Uran (Col) Cannondale, at 6-57
9. Giovanni Visconti (Ita) Movistar, at 7-47
10. Rafal Majka (Pol) Tinkoff, at 8-06
11. Bob Jungels (Lux) Etixx-Quick Step, at 8-06
13. Steven Kruijswijk (Ned) LottoNL-Jumbo, at 8-13
14. Esteban Chaves (Col) Orica-GreenEdge, st
Giro d'Italia 2016 overall standings after stage 20
1. Vincenzo Nibali (Ita) Astana, at 82-44-31
2. Esteban Chaves (Col) Orica-GreenEdge, at 52s
3. Alejandro Valverde (Esp) Movistar, at 1-17
4. Steven Kruijswijk (Ned) LottoNL-Jumbo, at 1-50
5. Rafal Majka (Pol) Tinkoff, at 4-37
6. Bob Jungels (Lux) Etixx-Quick Step, at 8-31
7. Rigoberto Uran (Col) Cannondale, at 11-47
8. Andrey Amador (CRC) Movistar, at 13-21
9. Darmin Atapuma (Col) BMC, at 14-09
10. Kanstantsin Siusou (Blr), at 16-20
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
Jack Elton-Walters hails from the Isle of Wight, and would be quick to tell anyone that it's his favourite place to ride. He has covered a varied range of topics for Cycling Weekly, producing articles focusing on tech, professional racing as well as cycling culture. He moved on to work for Cyclist magazine in 2017.
Are gravel races too challenging to broadcast?
FloSports and Life Time have mutually agreed to cease broadcast production for the Life Time Grand Prix
By Anne-Marije Rook • Published
The 5 Best Gravel Events You’ve Never Heard Of
The 5 Best Gravel Races You’ve Never Heard Of: Skull 120, Cascadia Super Gravel, Iceland's The Rift and Further and Peacham Fall Fondo
By Jacob Rathe • Published
‘I was rubbing shoulders with Nibali and Valverde’ - Oliver Knight gets starstruck at Vuelta a Burgos
UAE Team Emirates rider makes big step up in key race before the Vuelta a España
By Tom Thewlis • Published
Miguel Ángel López suspended by Astana-Qazaqstan over reported links to doctor under police investigation
Team suspend Colombian rider until circumstances of the Police investigation are clarified
By Tom Thewlis • Published