The 2014 Tour de France champion snatched the first of five top one-day races, Milan-San Remo, Tour of Flanders, Paris-Roubaix, Liège–Bastogne–Liège and Giro di Lombardia by pulling away from the pack on the ascent of the Poggio, seven kilometres from the finish.
The Bahrain-Merida rider, the first Italian to win the "Primavera" since 2006, looked back only in the final few metres when a group of top sprinters were breathing down his neck.
Australian Caleb Ewan (Mitchelton-Scott) and Arnaud Demare (Groupama-FDJ), the 2016 champion, were second and third respectively.
"I have to thank the team, who rode perfectly. I was able to hide in the group with (Sonny) Colbrelli, keeping an eye out and staying out of the wind," said Nibali.
"When I looked over my shoulder and saw the sprinters could not catch me, it was a good moment for me, but it is too early to say if it is the best win of my career."
Mark Cavendish (Dimension Data) suffered a spectacular crash, landing on his back after somersaulting after hitting road furniture.
Headwinds in the ascent to the Cipressa prevented the more aggressive riders attacking and the main bunch stayed compact until the Poggio, whose base is 10km from the finish line.
Nibali went solo near the summit and used his outstanding descending skills to open up a 13-second gap.
He had nine seconds over the pack at the end of the descent and then rode himself into the ground to prevail by a bike length and become the first grand-tour champion to win the race since Sean Kelly in 1992.