The Mercedes driver set a best time of 1m36.015s on his first run in Q3, with engineer Pete Bonnington telling him “that was an epic lap” after crossing the line.
Hamilton abandoned his lap on his second run in the middle sector after running wide out of the Turn 7 right-hander, but had done enough to secure pole by 0.319s from Red Bull driver Max Verstappen.
Verstappen was on a lap that was close to Hamilton’s time after two sectors on his second run, but a slow final sector put paid to his chances of taking pole position.
Verstappen said “this feels like a victory” after struggling today and yesterday with engine complaints.
Sebastian Vettel also failed to improve on his second run, ending up 0.613s down in third place and less than a tenth ahead of the second Mercedes of Valtteri Bottas.
Kimi Raikkonen was fifth for Ferrari, two tenths ahead of the second Red Bull of Daniel Ricciardo.
Sergio Perez was seventh, a second slower than Ricciardo, for Force India ahead of the Haas of Romain Grosjean.
Force India teammate Esteban Ocon survived a brush with the wall at the exit of Turn 21 to claim ninth place ahead of Renault’s Nico Hulkenberg.
McLaren’s Fernando Alonso was bumped out of the top 10 by Grosjean’s late improvement, leaving him 11th and fastest of those eliminated in Q2.
He missed out on a place in the top 10 shootout by just 0.107s having outpaced Renault driver Carlos Sainz, who failed to improve his time on his second run and complained of “absolutely no grip”.
Sauber pairing Charles Leclerc and Marcus Ericsson were 13th and 14th, albeit with seven tenths separating the duo.
Toro Rosso driver Pierre Gasly was 15th, lapping over two tenths slower than Ericsson.
Kevin Magnussen was the quickest to be eliminated in Q1 in 16th place after failing to improve on his second run and being shuffled into the drop zone by Ericsson
Toro Rosso driver Brendon Hartley was 17th, lapping two tenths off teammate Gasly but half-a-tenth ahead of McLaren’s Stoffel Vandoorne.
Williams pairing Sergey Sirotkin and Lance Stroll were a distant 19th and 20th, lapping 1.4s off the rest of the field