Nibali had bridged across to a move by Thibaut Pinot (FDJ) on the climb to Civiglo, before distancing his French rival on the descent and consolidating his lead on the run in to the final climb.
While Pinot was caught on the final small climb to San Fermo della Battaglia, Nibali continued to look strong as he held a comfortable lead to the finish in Como to the delight of the Italian crowds.
Julian Alaphilippe (Quick-Step Floors) took second place after attacking from a chase group on the final climb, while Gianni Moscon (Team Sky) sprinted to third place from a group of the other main contenders.
How it happened
The main break of the day consisted of six riders: Lorenzo Rota (Bardiani-CSF), Matthias Le Turnier (Cofidis), Pier Paolo De Negri (Nippo Vini Fantini), Lennard Hofstede (Team Sunweb), Jacques Janse Van Rensburg (Dimension Data), and Davide Ballerini (Androni-Sidermec), who took a little while to get away, but eventually opened their lead to a maximum of 12 minutes on the rolling first half of the 247km race.
Eventually it came down to Bahrain-Merida to begin to bring the lead down, the Middle Eastern team joined by Cannondale-Drapac and Movistar to just 1-17 as the race hit the base of the Madonna del Ghisallo climb with 70km remaining.
The start of the climb saw the start of the attacks, as a group of around eight riders attacked off the front of the peloton, which promptly split itself as Laurens de Plus (Quick-Step Floors) and Mickael Cherel (Ag2r La Mondiale) went on alone to mop up the disintegrating break, catching the last of the early escapees, Le Turnier, at the top of the climb.
That trio grew their lead on the descent towards the Muro di Sormano as a few more riders jumped out of the peloton to form an intermediate chase group, although with little more than a minute separating the peloton from the front of the race.
On to the Sormano and gesticulating at De Plus for not cooperating, Cherel accelerated to go solo at the front of the race. However the chasing group was going backwards as the peloton upped the pace behind, with Roglic the only rider able to put up much resistance, and was the last to be caught as the 25 per cent slopes really made themselves felt.
However Cherel was looking surprisingly fresh, cresting the climb with a 25-second lead over De Plus, with the peloton another 30-seconds back as they went on to the descent with 50km remaining.
The descent was technical and Cherel had a few close run-ins with the barriers, before De Plus had a disastrous moment as he took too much speed into a left-hand bend and went over the barriers, disappearing over the side of the road.
Medical services were quickly on the scene to tend to De Plus, and the rest of the riders safely made it back down onto valley roads with only Cherel left in the lead 50 seconds ahead of the peloton.
The next 20km were largely flat, but that didn’t deter another attack from the peloton as Philipp Gilbert (Quick-Step Floors) accelerated clear with Alessandro De Marchi (BMC Racing), who were then joined by Pello Bilbao (Astana) to form a three-man group 20 seconds ahead of the peloton.
That group worked well together to catch Cherel, but the peloton was working hard behind with FDJ keeping the pressure on ahead of Astana and Bahrain-Merida.
FDJ continued to set the pace on the early slopes of the next climb to Civiglo as Cherel dropped back from the break, before the rest of the escapees were caught with 19km remaining in the race.
However the race didn’t stay together for long as Gianni Moscon (Team Sky) tried to force the next selection with all of the main contenders forced to react. The Italian was quickly marked but Thibaut Pinot (FDJ) then made another move that looked more decisive.
The Frenchman quickly opened a sizeable gap, but that was made short work of by Vincenzo Nibali (Bahrain-Merida) who powered across from an elite chasing group.
Nibali led onto another technical descent and immediately started to push hard as he tried to distance Pinot, opening a lead of a seven seconds by the time the road flattened out with 10km remaining, and the chasing group another 40 seconds further back.
The final climb started with eight kilometres remaining and as the riders in the chase group refused to cooperate, the victory look set to be contested between Nibali and Pinot.
Both men were on their limit, but it was Nibali who was able to edge ahead second by second, cresting the final climb with a comfortable advantage.
Behind the attacks were still flying as Fabio Aru (Astana), Nairo Quintana (Movistar), and Diego Rosa (Team Sky) all tried their luck, but it was Julian Alaphilippe (Quick-Step Floors) who was able to catch Pinot by the top of the climb.
Alaphilippe pushed on on the descent, but he was riding for second place as Nibali enjoyed a solo victory in Como to the delight of the home crowds.
Nibali crossed the line to take the 50th win of his professional career 31 seconds ahead of Alaphilippe, while Gianni Moscon won the sprint for third place.
Il Lombardia 2017, Bergamo to Como (247km)
1. Vincenzo Nibali (Ita) Bahrain-Merida, in 6-15-29
2. Julian Alaphilippe (Fra) Quick-Step Floors, at 28 secs
3. Gianni Moscon (Ita) Team Sky, at 38 secs
4. Alexis Vuillermoz (Fra) Ag2r La Mondiale
5. Thibaut Pinot (Fra) FDJ
6. Domenico Pozzovivo (Ita) Ag2r La Mondiale
7. Fabio Aru (Ita) Astana, all at same time
8. Mikel Nieve (Esp) Team Sky, at 40 secs
9. Nairo Quintana (Col) Movistar, at 42 secs
10. Sergei Chernetski (Rus) Astana, at 47 secs