The general classification riders were safe in their positions after that point, but it was then that Gaviria capped a fearless display with a storming finish despite pressure from Bora-Hansgrohe and Lotto-Soudal.
"I would like to keep the jersey for longer than past year but we have a big stage on Sunday at Blockhaus".
Shalunev and Paterski had earlier worked hard over the first part of the stage, which saw the gap on the peleton up to three-and-a-half minutes heading into the more flat final 50km.
Thomas' fellow Briton Adam Yates remains four seconds further back on the same time as defending champion and home favourite Vincenzo Nibali and 2014 victor Nairo Quintana of Colombia.
He finished in seventh place, one spot behind Dimension Data teammate Kristian Sbaragli of Italy, with Colombian rider Fernando Gaviria (Quick-Step Floors) winning the 159km stage from Pedara to Messina.
Kwadwo Asamoah an unused substitute in Juventus 2-0 win over Monaco
The Italian was at his best as Juve beat Monaco 2-0 to take full control of their semi-final with the French league leaders. It looks like being a Real Madrid vs Juventus final in the Champions League this year.
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.
Gaviria's team-mate Bob Jungels of Luxembourg is still in the overall lead, maintaining his six-second advantage over Welsh Team Sky rider Geraint Thomas.
The 23-year-old only seemed to realise his error once the peloton had gone past him.
"We wanted to take some points because we were down a few".
"I think everyone's still finding their legs and sussing each other out but a good start. We were able to take the win here, now we'll leave the islands and head to the mainland and we'll see what happens". "I'm super happy that Fernando took the victory, but it cost me a lot of nerves here in Messina", Jungels said.