Ion Izzagirre (Bahrain-Merida) and Joe Dombrowski (Cannondale-Drapac) kept pressure on Špilak after the largely flat stage ended with a long, steep climb to the Tiefenbach Glacier at 2,780m.
The Katusha rider finished strongly to win the stage and take the overall lead from Domenico Pozzovivo (AG2R), who slipped to fourth overall.
Špilak is now in a strong position to repeat his 2015 overall win as he leads BMC’s Damiano Caruso by 52 seconds and Steven Kruijswijk (LottoNL-Jumbo) by 1min 5sec after the 166.3km stage from Zernez to Tiefenbachferner.
“Immediately from the start this morning I felt that I had good legs,” Špilak said. “Yesterday it was 30 degrees, but today it was 20 and this is better for me.
“We had a plan for today and the team was so good. Not to perform well was not an option. [Baptiste] Planckaert and [Jonathan] Restrepo went with the early break while the others stayed with me to keep me out of the wind. [Rein] Taaramäe was getting our drinks and then at the end, he was still with me on the final climb and did a great job.
“With 7-8k to go, I dropped Rein and Joe Dombrowski. Maybe that was too far from the finish, but what else could I do? I had to take the jersey for my team.
“Now it is 52 seconds to Caruso and more than one minute to Kruijswijk. Tomorrow is a sprinter’s stage so we should be able to control that and then a long TT on the last day. And yes, I am not so bad in the TT.”
A group of 18 riders, including previous stage winners Peter Sagan (BORA-hansgrohe) and Michael Matthews (Sunweb), got the all clear. After 60km the gap hovered just under three minutes but the AG2R led peloton kept the breakaway on a tight leash, working diligently for race leader Domenico Pozzovivo.
The gap of the breakaway was down to two minutes 25km before the start of final Hors Catégorie climb, a 14.2km ascent with an average gradient of 9.5 per cent.
Tim Wellens (Lotto Soudal), the last survivor of the breakaway was caught in the early slopes of the climb and with 15km to go the punishing gradients started to quickly whittle down the peloton, spearheaded by Katusha-Alpecin and Bahrain-Merida.
The key moment of the stage occurred shortly after, as Pozzovivo dropped from the main group, unable to follow the tempo being set by Špilak's Katusha-Alpecin team.
Soon the front group had dwindled down to just a handful of riders, including Špilak, Caruso, Izagirre, Kruijswijk, Joe Dombrowski, and Movistar’s Marc Soler.
The double digits gradients started to eat into the riders’ resolve and with eight kilometres to go, with Pozzovivo 1min 30sec in arrears and only Špilak and Dombrowski remained in front before the eventual stage winner went solo.
Izagirre bridged to Dombrowski as they passed the 3km to go banner and pushed hard to make it across to Špilak, but he ran out of road.
The mountains classification jersey remains on the shoulders of Lasse Norman Hansen (Aqua Blue Sport), while World Champion Sagan extended his lead in the points classification.