Bennett hit the front and opened his sprint up first, but QuickStep Floors had dropped Gaviria off in perfect position for the Colombian to power to a dominant stage win.
Having won in the crosswinds on stage three, this was a very different sprint, but the winning margin was no less impressive.
Bennett held on for third, pipped to second place by Wilier Triestina-Selle Italia’s Jakub Mareczko.
It was QuickStep celebrating on the podium though – now double stage winners, and holders of both the maglia rosa and maglia ciclamino.
Giro d’Italia 2017: stage five – result
1) Fernando Gaviria (COL) – QuickStep Floors – 3.40.11hrs
2) Jakub Mareczko (ITA) – Wilier Triestina-Selle Italia – ST
3) Sam Bennett (IRL) – Bora-hansgrohe
4) Andre Greipel (GER) – Lotto-Soudal
5) Phil Bauhaus (GER) – Team Sunweb
6) Kristian Sbaragli (ITA) – Dimension Data
7) Ryan Gibbons (RSA) – Dimension Data
8) Roberto Ferrari (ITA) – UAE Team Emirates
9) Jasper Stuyven (BEL) – Trek-Segafredo
10) Enrico Battaglin (ITA) – LottoNL-Jumbo
General classification
1) Bob Jungels (LUX) – QuickStep Floors – 23.22.07hrs
2) Geraint Thomas (GBR) – Team Sky +6”
3) Adam Yates (GBR) – Orica-Scott +10”
4) Domenico Pozzovivo (ITA) – Ag2r-La Mondiale – ST
5) Vincenzo Nibali (ITA) – Bahrain-Merida
6) Nairo Quintana (COL) – Movistar
=) Tom Dumoulin (NED) – Team Sunweb
8) Bauke Mollema (NED) – Trek-Segafredo
9) Tejay van Garderen (USA) – BMC Racing
10) Andrey Amador (CRC) – Movistar