Britain's Simon Yates had his Giro d'Italia lead cut in half after a dramatic final climb on stage 18.
Young German Max Schachmann capitalised on a breakaway to take the stage win after 196km to Prato Nevoso.
But all the drama was behind him as Yates lost 28 seconds to Tom Dumoulin, in second, and Chris Froome in fourth.
It was the first time the 25-year-old has cracked in this race, his lead now down to 28 seconds with three stages left - the final one in Rome.
With the last 15km all uphill at an average gradient of 7%, Yates would have feared a move from the powerful Dumoulin, of the Netherlands.
But it was Briton Froome who made the first telling attack within the final 2km, and while Dumoulin and Italy's Domenico Pozzovivo went with him, the race leader could not respond.
Suddenly he was vulnerable, and his rivals sensed blood.
Froome had team-mate Wout Poels up the road to help, at least until the Dutchman took a wrong turn on a hairpin, and with Dumoulin working with him, the gap began to stretch and stretch.
Yates had performed superbly in Tuesday's time trial but perhaps that effort had taken a bigger toll than others realised.
Dumoulin stays second overall, with Pozzovivo now two minutes 43 seconds back in third, and Froome still fourth but closing to within three minutes 22 seconds of the lead.
Yates said afterwards: "I didn't have great legs, but I did the best I could. I'm still in front, so it's all good."
Both Friday and Saturday are brutal mountainous days before Sunday's processional stage around Rome, and a race that appeared Yates' to lose is suddenly wide open once again.
A happy looking Dumoulin said: "At 2km to go, I tried to see what was possible. Then Froome attacked, and I suddenly found out he [Yates] was dropped, and that was nice.
"The coming two days are going to be even harder than today, so we'll just have to see."
Earlier, a 12-man break devoid of any threats to the general classification had 15 minutes over the peloton for much of the closing 50km before Boy van Poppel tried a solo break with 18km to go.
The effort cost the Dutchman and he dropped back down as the break began to splinter on the final climb.
With 8km to go, a group of six began to attack each other - and as the resort's outskirts were reached, Schachmann and Italian Mattia Catteneo were out on their own.
The general classification contenders were still 13 minutes back as Cattaneo tried to lead it out but the two were so cautious that the veteran Ruben Plaza was able to catch them with 900m to go.
And it was the 24-year-old Schachmann who took his first grand tour stage win, with Plaza second on the day and Cattaneo third.
Stage 18 results:
1. Maximilian Schachmann (Ger/Quick-Step Floors) 4hrs 55min 42sec.
2. Ruben Plaza (Spa/Israel Cycling Academy) +10secs
3. Mattia Cattaneo (Ita/Androni-Sidermec-Bottecchia) +16secs
4. Christoph Pfingsten (Ger/Bora-Hansgrohe) +1min 10secs
5. Marco Marcato (Ita/UAE Team Emirates) +1min 26secs
6. Michael Morkov (Den/Quick-Step Floors) +1min 36secs
7. Viacheslav Kuznetsov (Rus/Katusha Alpecin) +1min 52secs
8. Jos van Emden (Ned/LottoNL-Jumbo) +3mins 22secs
9. Alex Turrin (Ita/Wilier Triestina-Selle Italia) +3mins 29secs
10. Davide Ballerini (Ita/Androni-Sidermec-Bottecchia) +5mins 09secs
12. Domenico Pozzovivo (Ita/Bahrain-Merida) +11mins 03secs
13. Tom Dumoulin (Ned/Team Sunweb) same time
14. Chris Froome (GB/Team Sky) same time
20. Simon Yates (GB/Mitchelton-Scott) +11mins 31secs
24. Thibaut Pinot (Fra/Groupama-FDJ) +11mins 36secs
1. Simon Yates (GB/Mitchelton-Scott) 75hrs 06mins 24secs
2. Tom Dumoulin (Ned/Team Sunweb) +28secs
3. Domenico Pozzovivo (Ita/Bahrain-Merida) +2mins 43secs
4. Christopher Froome (GB/Team Sky) +3mins 22secs
5. Thibaut Pinot (Fra/Groupama-FDJ) +4mins 24secs
6. Miguel Angel Lopez (Col/Astana Pro Team) +4mins 54secs
7. Rohan Dennis (Aus/BMC Racing Team) +5mins 09secs
8. Pello Bilbao (Spa/Astana Pro Team) +5mins 54secs
9. Richard Carapaz (Ecu/Movistar Team) +5mins 59secs
10. Patrick Konrad (Aut/Bora-Hansgrohe) +7mins 05secs