Nibali attacked with three kilometres to go on the steep ascent to Tre Cime di Lavaredo, the three-week classic's highest point at an altitude of 2,304 metres.
On the final stages of the climb, the road was surrounded by huge banks of snow.
It was Nibali's second stage victory of the race, having also won Thursday's mountain time trial.
His performance came in stark contrast to the developments at the race Friday, when the 19th stage was cancelled due to snow and it was announced that 2007 Giro winner Danilo Di Luca tested positive for EPO in a surprise check at his home before this year's race.
"I wanted to leave a mark," Nibali said. "After what happened yesterday I wanted to show that I was fighting right up to the end."
An Italian with the Astana team, Nibali clocked five hours 27 minutes 41 seconds over the 211-kilometre leg, which began in Silandro and passed through the renowned ski resort of Cortina d'Ampezzo.
The 20th stage was originally supposed to include a few more climbs but the route was altered due to the adverse weather conditions and snow covering some roads.
Colombian pair Fabio Duarte and Rigoberto Uran finished second and third, 17 and 19 seconds behind, respectively.
Uran moved up from third to second overall, 4:43 behind Nibali. Cadel Evans, the 2011 Tour de France winner, dropped to third, 5:52 back.
Evans finished about 1 1/2 minutes behind Nibali in the stage, which was also characterized by sub-freezing temperatures.
Nibali had to have hot tea poured over his hands to relieve the cold after crossing the line, so he could take off his wet gloves without pain.
Along the final climb, Nibali had to push fans away who kept clinging to him.
"I was worried one of them might slip," he said. "I want to thank all the people who waited for me up here at the top and the organizers for allowing us to get here."
Before the stage started, Dutch rider Robert Gesink, one of the pre-race favourites, withdrew from the race.
The race ends on flat ground in Brescia on Sunday with a 197-kilometre stage starting in Riese Pio X.
Nibali also took the red points jersey from Mark Cavendish, but the British sprinter can reclaim it by winning the final stage.Suggest a correction