Alexandre Geniez (Ag2r La Mondiale) took his third victory of the season as he bridged across to a late attack before sprinting to the win in a photo finish in the Tre Valli Varesine.
However, with less than a kilometre to go, Geniez bridged across with Diego Ulissi, before launching a perfectly timed sprint to come around Nibali and Pinot in the final few metres.
The day's early break consisted of five riders, with Daniel Turek (Israel Cycling Academy), Alessandro Tonelli (Bardiani CSF), Nych (Gazprom Rusvelo), Diego Rubio (Caja Rural), Ettore Carlini (D'Amico Utensilnord) and Marco Bernardinetti (Amore e Vita) up the road.
Team Sky controlled the front of the peloton over the hilly parcours, bringing the gap below five minutes as the race entered the final 100km.
That gap clearly wasn't enough for Tulek, who split the early break with 60km to go, dragging Tonelli and Rubio with him. However despite that attack the gap to the peloton continued to fall, encouraging flurries of attacks off the front of the bunch.
With 40km remaining, and the break's lead down to just 45 seconds, three riders - Pierre-Roger LaTour (Ag2r La Mondiale), Redi Halilaj (Amore e Vita) and Carlos Verona (Orica-Scott) - were able to get away, bridging across to the leaders while Wout Poels (Team Sky) made a brief but ultimately unsuccessful attempt to join them.
However another counter-attack, from Bora-Hansgrohe's Pawel Poljanski and Androni Sidermec's Fausto Masnada, was able to get across, giving the front group of seven riders at the front of the race.
Bahrain-Merida were leading the chase in the peloton behind and slowly chipping into the break's lead, when Verona attacked from the escape, going solo in search of a first professional victory.
The Spanish rider enjoyed a lead of 20 seconds going onto the final 12.8km lap around the town of Varese as Team Sky joined Bahrain-Merida in the pursuit.
That collaboration put paid to the hopes of Verona, and the Orica-Scott rider was caught with nine kilometres remaining, with Giovanni Visconti (Bahrain-Merida) pushed on on the descents.
The final climb came with slightly over three kilometres to go and it was no surprise to see Vincenzo Nibali on the attack, with Thibaut Pinot suffering to jump on the Italian's wheel.
That duo collaborated to hold off a chasing group, which was within touching distance coming under the flamme rouge, allowing Alexandre Geniez and Diego Ulissi to jump across.
Tre Valli Varesine 2017, Saronno to Varese (192.8km)
1. Alexandre Geniez (Fra) Ag2r La Mondiale, in 4-49-08
2. Thibaut Pinot (Fra) FDJ
3. Vincenzo Nibali (Ita) Bahrain-Merida
4. Diego Ulissi (Ita) UAE Team Emirates, all at same time
5. Davide Villella (Ita) Cannondale-Drapac, at 7 secs
6. Sam Oomen (Ned) Team Sunweb
7. Gianni Moscon (Ita) Team Sky
8. Fabio Aru (Ita) Astana, all at same time
9. Daniel Martinez (Col) Wilier Triestina, at 17 secs
10. Michael Albasini (Sui) Orica-Scott, at 18 secs
Chris Froome reveals the race he'd like to win before retirement
The seven-time Grand Tour winner speaks about how tech and data help younger riders get to the top earlier and how it helps recovery
By Tim Bonville-Ginn •
Coldplay perform using energy powered by 60 cyclists
The cyclists powered the music performances at the inaugural Earthshot Prize
By Ryan Dabbs •