The Astana team leader emerged from the fog and snow to cross the line in 5hr 27min 41sec, 17sec ahead of a trio of Colombians, one of whom, Rigoberto Uran, deposed Australian Cadel Evans from second place overall.
On a stage that was stripped of several climbs due to severe weather conditions and fears over the safety of riders on slippery descents, Nibali attacked in the final kilometres of the 7km ascent to all but secure victory ahead of Sunday's final, flat stage into Brescia.
Colombian Fabio Duarte (Team Colombia) finished second at 17sec with Uran (Sky) in third at 19 and Carlos Betancur (AG2R) finishing two seconds further adrift.
Evans, who began the day in second overall at 4:02 behind Nibali, struggled to follow when Nibali's turn of pace prompted Uran and Betancur to follow suit.
The BMC leader finished over a minute behind to slip to third overall at 5:52 but is 56secs ahead of Lampre's contender, Michele Scarponi.
Nibali's triumph would be his first on the Giro d'Italia, the Sicilian having won the Tour of Spain in 2010 and finished runner-up on his home race in 2011 and third overall at last year's Tour de France.
Nibali not only won in severe conditions but had to ward off off well-wishing supporters as he pushed his way up the final ascent.
"I had to push away a few supporters, I thought they would make me crash," said Nibali.
"But finishing the race with a win like this is the cherry on the cake."
A day after the 19th stage was cancelled due to snow and sub-zero temperatures in the Dolomites, the peloton tackled a 20th stage that was re-routed and devoid of three major climbs.
With only two real climbs before the final ascent, a four-man breakaway formed early and went on to build a lead of just over eight minutes on the main bunch.
But when the peloton started to race, their advantage steadily evaporated to two-and-a-half minutes with 24 km to the finish.
Sensing the danger, Yaroslav Popovych attacked his four-man lead group but was quickly countered by Katusha's Pavel Brutt.
Brutt enjoyed a spell on his own but crested the 8km-long Tre Croci climb with a 26sec lead on Dutchman Pieter Weening with a reduced main peloton crossing over at 48sec.
Both riders were swallowed up early on the 7km ascent to Tre Cime, which featured passages at a crushing 18 percent gradient.
Attacks and counter-attacks came and went but it was Astana's pace-setting that allowed Nibali to ease away from his rivals inside the final 3km.
While Uran's result will allow him to finish runner-up, Betancur's commendable third place finish - after he fought to get back to the group following a mechanical problem - put him into the top five and secured the white jersey for the best young rider.
"I really wanted this jersey, it was my objective since the start," said Betancur, who had been duelling with overnight leader Rafal Majka of Poland.
Results from the 20th and penultimate stage of the Giro d'Italia, a 210km re-routed ride from Silandro to Tre Cime di Lavaredo:Stage
1. Vincenzo Nibali (ITA/AST) 5hr 27min 41sec, 2. Fabio Duarte (COL/COL) at 17sec, 3. Rigoberto Uran (COL/SKY) 19, 4. Carlos Betancur (COL/ALM) 21, 5. Fabio Aru (ITA/AST) 44, 6. Franco Pellizotti (ITA/AND) 48, 7. Domenico Pozzovivo (ITA/ALM) 54, 8. Damiano Caruso (ITA/CAN) 58, 9. Darwin Atapuma (COL/COL) 1:00, 10. Rafal Majka (POL/TST) 1:04
General classification
1. Vincenzo Nibali (ITA/AST) 79hr 23min 19sec, 2. Rigoberto Uran (COL/SKY) at 4min 43sec, 3. Cadel Evans (AUS/BMC) 5:52, 4. Michele Scarponi (ITA/LAM) 6:48, 5. Carlos Betancur (COL/ALM) 7:28, 6. Przemyslaw Niemiec (POL/LAM) 7:43, 7. Rafal Majka (POL/TST) 8:09, 8. Benat Intxausti (ESP/MOV) 10:26, 9. Mauro Santambrogio (ITA/VIN) 10:32, 10. Domenico Pozzovivo (ITA/ALM) 10:59