The Astana team leader pointed a finger skyward as he burst out of a breakaway bunch at the end of the 201-kilometer (125-mile) ride over nine rolling ascents and through the heath of northern England. Peter Sagan of Slovakia was second, and Belgium's Greg van Avermaet was third -- each two seconds behind.
Over the last six kilometers, several of the pre-race favorites to win the three-week race played a cat-and-mouse game, quickly exchanging leadership of the breakaway bunch. But Nibali, a 29-year-old rider who has won both the Italian Giro and Spanish Vuelta, timed his attack perfectly -- bursting ahead with less than 2 kilometers to go and holding off surging chasers.
"It was a fabulous day for me, I led a good action," said Nibali, who collected his first Tour stage win and first yellow jersey. "It was difficult. There was a lot of headwind ... I had the luck to attack at the right moment."
Marcel Kittel of Germany, a powerful sprinter who often struggles on climbs, trailed nearly 20 minutes back and lost the yellow jersey that he had captured by winning Stage 1.
Nibali was up front with a bunch including defending Tour champion Chris Froome of Britain and Spanish two-time winner Alberto Contador -- each of whom burst to the front of the escaping bunch near the end. Others in the group included 25-year-old American riders Andrew Talansky and Tejay van Garderen.
"It was a very hard day but the home crowd support was great," said Froome, the Team Sky leader. "I'm tired, but I hope everyone's tired after a day like today."
Tinkoff-Saxo Bank leader Contador said: "Today was a day when you really needed to be careful ... There are thousands and thousands of people. It's great but it's also dangerous."
Overall, Nibali leads 20 other riders by two seconds, including Froome in fifth place and Contador in eighth.
Massive crowds lined the route from York to Sheffield. One of the British stars in the race, Mark Cavendish, dropped out before the stage after pain from a separated right shoulder sustained in a crash Saturday.
While Yorkshire doesn't have ascents on a par with the Alps or Pyrenees in France, riders faced nine low- to mid-grade climbs. The hardest was the 4.7-kilometer Holme Moss pass, and the steepest was also the shortest: The 800-meter Jenkin Road pass, with an average gradient of 10.8 percent -- just 5 kilometers from the finish line.
England is hosting the first three stages of the three-week race before it enters France.
New roads for cycling's greatest race also mean new audiences, some of whom are so enthusiastic and eager for a "selfie" with the pack that they don't realize the hazards of getting too close to the riders as they go by. There are simply too many people for barriers that race organizers erect in crowded spots, making the course more treacherous for the riders.
Kittel and Giant-Shimano teammate Koen De Kort of the Netherlands were among those who crashed during the day. Team sporting director Christian Guiberteau said the German sprint star was unharmed, sustaining "just a little crash because there are so many people on the roadside."
Simon Gerrans, who crashed with Cavendish in Saturday's stage, also spilled -- as did van Garderen and Joachim Rodriguez, the third-place finisher in the 2013 Tour. All recovered to finish the stage.
French rider Thomas Voeckler said overenthusiastic crowds had added to the challenges, including hearing the squeaks of rivals' brakes.
"People really need to stay on the side of the road with their strollers and children," Voeckler said.
On the up-and-down, picturesque course, the 197-rider peloton scaled a narrow, cobblestone hill in Haworth, where the Bronte sisters -- the famous 19th-century novelists -- lived when their father was parson in the town.
Monday's stage should be a far less grueling ride: Riders cover 155 kilometers (96 miles) from university town Cambridge to London, where the pack will finish on the Mall not far from Big Ben and Westminster Abbey.