Simon Yates clings onto Pink Jersey ahead of Brutal Queen Stage
Max Schachmann wins stage from the breakaway as Yates loses time as his rivals attack, his lead is halved to just 28 seconds
Young German Max Schachmann took the stage win to Prato Nevoso from the breakaway
Behind him as Simon Yates lost 28 seconds to Tom Dumoulin, in second, and Chris Froome in fourth.
It was the first time Yates has cracked, his lead now down to 28 seconds with two mountain stages left - plus the final one in Rome.
The Prato Nevoso finish was 15km uphill at an average gradient of 7%, Yates eyeing defending champion Tom Dumoulin.
But it was Briton Chris Froome who put in the first big attack within the final 2kms, and Dumoulin and Italy's Domenico Pozzovivo went with him, Yates just couldn't respond.
Froome had team-mate Wout Poels up the road to help, he took a wrong turn and went off course! Dumoulin worked with him and the gap began to grow.
Yates performed superbly in Tuesday's time trial but perhaps the effort had took a bigger toll than first realised.
Dumoulin issecond overall, with Pozzovivo now two minutes 43 seconds behind in third, and Froome still fourth but closing to within three minutes 22 seconds of the lead.
A shocked and stunned Yates bravely 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."
Friday and Saturday are brutal mountainous days before Sunday's processional stage around Rome, now suddenly the race is 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.
VIDEO: 2018 Giro d'Italia Stage 18 Highlights
2018 Giro d'Italia Stage 18 Top 10
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
2018 Giro d'Italia GC after Stage 18
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 54sec
9. Richard Carapaz (Ecu/Movistar Team) +5mins 59secs
10. Patrick Konrad (Aut/Bora-Hansgrohe) +7mins 05secs