It teed up the sprint finish, and Max Richeze dropped Gaviria off at the front – and from there, there was never going to be another winner.
Such was the lead-out, the Argentine finished fifth himself, raising his arms with his Colombian team-mate.
Gaviria will now have the chance to make it four stage wins on stage 13, a pan-flat route and probably the final chance for the fast men at this year’s race.
Giro d’Italia 2017: stage 12 – report
1) Fernando Gaviria (COL) – QuickStep Floors – 5.18.55hrs
2) Jakub Mareczko (ITA) – Wilier Triestina-Selle Italia – ST
3) Sam Bennett (IRL) – Bora-hansgrohe
4) Phil Bauhaus (GER) – Team Sunweb
5) Max Richeze (ARG) – QuickStep Floors
6) Ryan Gibbons (RSA) – Dimension Data
7) Sacha Modolo (ITA) – UAE Team Emirates
8) Andre Greipel (GER) – Lotto-Soudal
9) Jasper Stuyven (BEL) – Trek-Segafredo
10) Roberto Ferrari (ITA) – UAE Team Emirates
General classification
1) Tom Dumoulin (NED) – Team Sunweb – 52.41.08hrs
2) Nairo Quintana (COL) – Movistar +2.23
3) Bauke Mollema (NED) – Trek-Segafredo +2.38
4) Thibaut Pinot (FRA) – FDJ +2.40
5) Vincenzo Nibali (ITA) – Bahrain-Merida +2.47
6) Andrey Amador (CRC) – Movistar +3.05
7) Bob Jungels (LUX) – QuickStep Floors +3.56
8) Tanel Kangert (EST) – Astana +3.59
9) Domenico Pozzovivo (ITA) – Ag2r-La Mondiale +4.05
10) Inur Zakarin (RUS) – Katusha +4.17