Vettel was given a 10-second stop and go penalty for driving into the Mercedes driver.
Hamilton secured the 66th pole of his career in Baku.
Red Bull were fastest in both the practice sessions with Ferrari and Mercedes struggling.
However, Briton insists he is happy at Mercedes and is currently thinking about how to beat the Scuderia.
Sebastian Vettel finished inside the top two in the first six races that includes three wins.
Three-time world champion says he does not recall discussing the possibility of stopping at the end of 2017.
The now retired Nico Rosberg won the first ever race at the Baku City Circuit in Azerbaijan last season.
Hamilton is contracted to the Mercedes F1 team until the end of the 2018 season.
Mercedes returned to form with a dominant one-two finish at the Canadian Grand Prix on 11 June.
Williams chief technical officer says Brazilian had 'ruthless' streak that Hamilton lacks.
World champion dismisses Toto Wolff suggestion he could return to the sport.
Briton closes to within 12 points of the championship leader after sixth career win in Montreal.
Mercedes secure their first one-two of the season at the Circuit Gilles Villeneuve in Montreal.
Lewis Hamilton matches Ayrton Senna's career pole total.
Three-time world champion was presented with one of the Brazilian's race-worn helmets in Montreal.
Hamilton has qualified on pole position five times at the Canadian Grand Prix
Vettel leads Hamilton in the drivers' championship while Ferrari are ahead of Mercedes in the team battle.
Two-time world champion could walk away from the sport if the calendar is extended.
Alonso is out of contract with McLaren at the end of the season.
Executive director Zak Brown says Japanese manufacturer have let themselves down during partnership.
Ferrari come into the Canadian Grand Prix leading both the Drivers' and Constructors' championship.
Toto Wolff says the Briton is more driven than ever to claim a fourth world title.
Silver Arrows chief admits for the first time that Ferrari are the favourites for world title.
Honda power unit will hinder the team at the Circuit Gilles Villeneuve admits boss Eric Boullier.
Hamilton questioned the quality of the IndyCar Series after rookie Alonso qualified P5 in his first attempt.
Two-time world champion still has hopes of regaining his crown.
Hamilton finished seventh in Monaco and now trails Vettel by 25 points in the drivers' championship.
Three-time world champion had previously questioned the level of quality in the American racing series.
Hamilton finished the Monaco Grand Prix in seventh place after starting in 13th.
Four-time world champion beats Kimi Raikkonen in the principality thanks to successful overcut.