Primoz Roglic of the Jumbo-Visma team won an uphill battle to virtually assure himself a Giro d'Italia title and earn some redemption for a meltdown in similar circumstances three years ago.
Roglic overtook overnight leader Geraint Thomas on an uphill individual time trial from Tarviso to Monte Lussari despite the horror of a late chain slip.
The penultimate day time trial has haunted the Slovenian since he lost the 2020 Tour de France in the same manner as Tadej Pogacar overtook and stormed to triumph.
On Saturday, Ineos Grenadiers leader Thomas was already trailing by 16 seconds when Roglic suffered a heart-stopping mechanical problem, which he dealt with only for team mechanics to waste time demanding he switch bikes.
Roglic held his nerve and powered up the steep final incline engulfed by screaming fans waving Slovenian flags.
The three-time Vuelta a Espana winner even accelerated with everything he had to the finish line to finish on 44min 23sec.
Thomas needed to finish within 26 seconds to retain the lead but as he edged agonisingly over the final 400m it became clear that victory belonged to Roglic and the crowds on the mountaintop barely 20km from the Slovenian border appeared relieved.
The 37-year-old Thomas has never been dominant in the mountains and despite digging into deep reserves his efforts would only earn the 37-year-old second place.
Sunday's 21st and final stage is a flat run around Roma. Roglic leads Thomas by 14 seconds with Portugal's Joao Almeida in third.
dmc/pb