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.
The popular Valtteri Bottas's first win was warmly received by his fellow drivers and the paddock, Hamilton hugging him after he had jumped into the arms of his crew and Sebastian Vettel joining the reception, Russian President Vladimir Putin also present for congratulations and prize giving.
Ferrari achieved a front row lockout for the first time in 127 races going back to the 2008 French Grand Prix, where Kimi Raikkonen took pole.
It was Sebastian Vettel's third win in Bahrain and the 44th of his career, a landmark that left him satisfied with his and the team's work which proved that Ferrari, who employed an aggressive strategy, are back as championship contenders.
Valtteri Bottas' lap was comfortably faster than Nico Rosberg's pole time last year of 1:29.493, but the overall speed of the new era 'fatter-and-faster' machines was less notable in the desert heat than it had been at the two previous races.
Sebastian Vettel survived a scare on Friday as he and Ferrari proved they are back as serious contenders for this year's world championship by topping both opening practice sessions ahead of this weekend's Bahrain Grand Prix.
Fernando Alonso is a two-time Formula 1 World Champion who currently races for British team McLaren.
Mercedes driver Lewis Hamilton steered clear of a chaotic start to the Chinese Grand Prix and coasted to victory on Sunday, claiming his fifth title in Shanghai
The signs point to another furious battle between Mercedes and Ferrari but with rain forecast for the Chinese Grand Prix race day, Red Bull's Daniel Ricciardo could fancy his chances after qualifying fifth.