Jungels, who took the race lead from Quick Step teammate Fernando Gaviria after a fourth-stage finish on Mount Etna, maintained his six-second advantage on Sky rider Thomas as Gaviria snatched the stage win.
But at the conclusion of an undulating ride from the foot of Mount Etna to Messina that brought an end to two stages on Sicily, the crowd was left baffled as young Slovenian Luka Pibernik starting celebrating fully 6km from the finish.
As the peloton raced towards the finish line for the first time, signalling the start of a final, 6km closing circuit, Pibernik launched a solo attack that held all the way to the finish line, where he sat up and spread his arms in victory.
But he was celebrating alone.
As thousands of puzzled fans looked on, 23-year-old Pibernik quickly realised his embarrassing gaffe before being swallowed up by the peloton as they began the final circuit.
Bahrain team leader and defending Giro champion Vincenzo Nibali later explained what had confused his young teammate. “The battery on his radio earpiece ran out. We tried calling him back to tell him, but he couldn't hear us. But he's young, things like that can happen,” said Nibali.
Gaviria, making his Giro and Grand Tour debut, emerged from Irishman Sam Bennett's back wheel in the final 200 metres of a long and wind-hit home straight to claim his second victory after breaking his Giro duck on stage three.
In doing so, the 22-year-old from Colombia became only the second rider this century, after former champion Damiano Cunego, to claim two stages on the race before his 23rd birthday.
As the sprinters' teams battled to move their stage contenders to the front, Jungels remained alert to late attacks from his pink-jersey rivals and held off Thomas, but said the “crazy” circuit made it a nervous finale.
“It was a dangerous and crazy final to be honest. I'm super happy that Fernando took the victory, but it cost me a lot of nerves here in Messina,” Jungels said.
“It was amazing to see so many people on the streets, but it's also sometimes very dangerous because people want to take the pictures and selfies and whatever, and they come closer and closer to the road.
“When there's a bunch of 200 people (cyclists) it's dangerous, but that's cycling.”
Gaviria's victory earned him the sprinter's “ciclamen” jersey for the points competition.
“I'm happy with two victories, the legs are now responding the way we wanted,” said Gaviria.
“We wanted to take some points because we were down a few. We wanted to take this jersey, we managed to get the points we needed and we did it in the best way.”
Italian Jakub Mareczko finished second with Bennett third.
After travelling to the mainland, the race resumes on Thursday with a 217km sixth stage from Reggio Calabria to Terme Luigiane that will offer the sprinters another chance for glory.
By Justin Davis