In his 50th race for Ferrari, the four-time champion German controlled the contest from pole position in stifling heat to reel off his first win in five races since the Monaco Grand Prix.
Sebastian Vettel took pole position for Sunday's Hungarian Grand Prix ahead of Ferrari team-mate Kimi Raikkonen in qualifying on Saturday.
Mercedes' Lewis Hamilton is bidding for a record sixth win in this weekend's Hungarian Grand Prix
The Briton finished comfortably clear of Mercedes teammate Valtteri Bottas with Ferrari's Kimi Raikkonen third.
Lewis Hamilton thrilled homes fans to grab pole ahead of Ferrari duo Kimi Raikkonen and Sebastian Vettel.
Sebastian Vettel leads the drivers standings on 171 points from Lewis Hamilton on 151 and Valtteri Bottas placed third on 136.
The Finn clocked a best lap of one minute and 4.251 seconds to outpace championship leader Sebastian Vettel of Ferrari by four hundredths of a second.
Force India COO Szafnauer said that it makes sense to change the team's name.
Sebastian Vettel, who had accused the Briton of brake-checking him, had served his penalty during the race after the stewards decided his actions added up to "dangerous driving". Hamilton was not reprimanded or punished.
Vettel was penalised for dangerous driving after deliberately crashing into Hamilton as Red Bull's Ricciardo won the title in Baku.
Lewis Hamilton claimed the 66th pole of his career, leaving him two shy of Michael Schumacher's record of 68.
It was the three-time champion's sixth victory at the Circuit Gilles Villeneuve -- where he claimed his maiden triumph in 2007 -- as well as his third this season and the 56th of his career.
It was Lewis Hamilton's 65th career pole position, moving him level with Brazilian legend Ayrton Senna.
Sebastian Vettel's third win of 2017 increased his lead over Mercedes' Lewis Hamilton in the drivers' world championship to 25 points.
Kimi Raikkonen, who had not taken pole position for 128 races stretching back to the French Grand Prix of 2008, dominated the afternoon's action to clock a fastest lap of one minute and 12.178 seconds.
Lewis Hamilton roared back into serious contention for a fourth drivers' world title on Sunday when he drove to a well-judged victory for Mercedes in a dramatic Spanish Grand Prix.
It was the 64th pole of Hamilton's career, lifting him to within one of his childhood hero Brazilian Ayrton Senna, on 65, and four from German Michael Schumacher on 68.
Lewis Hamilton heaped praise on his Mercedes team after he and team-mate Valtteri Bottas dominated practice ahead of this weekend's Spanish Grand Prix.