Lewis Hamilton narrowly beat Ferrari's Kimi Raikkonen to pole position for Formula 1's final Malaysian Grand Prix, as title rival Sebastian Vettel's Ferrari suffered engine problems and qualified last.
Mercedes struggled to get its upgraded F1 car working properly throughout the free practice sessions at the Sepang circuit, but turned things around just in time for Hamilton to get the job done in qualifying.
Hamilton's first flying lap in Q3 proved just enough in the end, as Raikkonen - who was fastest of all in Q2 - fell short by just 0.045 seconds after locking up at the final corner.
The second Mercedes of Valtteri Bottas was not so comfortable as Hamilton in qualifying, struggling particularly through the second sector. Bottas ended up only fifth fastest, behind both Red Bulls.
Max Verstappen split Raikkonen and Hamilton in Q2, but fell back in Q3, ending up third fastest, almost half a second away from pole. Team-mate Daniel Ricciardo was only half a tenth further back in fourth.
Vettel should have been among the fight for pole, having set the pace on Friday, but his Ferrari suffered a problem in final practice, so Ferrari worked through the break between sessions to change his engine.
Vettel made it out for the start of Q1, but reported a loss of drive, which he described as feeling "like I have no turbo", that he couldn't fix with the switch changes suggested by his team.
Vettel was forced back to the pits without setting a time and couldn't return to the track, leaving him last in the classification.
This could strike another serious blow to his world championship challenge, after losing his points lead to Hamilton after crashing out on lap one last time out in Singapore.
Esteban Ocon took advantage of Vettel's absence to post the sixth quickest time for Force India, ahead of Stoffel Vandoorne's McLaren, Nico Hulkenberg's Renault, Force India team-mate Sergio Perez, and the second McLaren of Fernando Alonso.
Felipe Massa and Jolyon Palmer (who was investigated but not punished for colliding with Verstappen in final practice) were both dumped out of the top 10 in the dying moments of Q2, as Perez, Vandoorne and Alonso all leaped ahead with quicker lap times.
Massa ended up an agonising 0.024s away from making the cut in 11th, ahead of Palmer, Williams team-mate Lance Stroll - who complained of a bad outlap compromising his second run - and the Toro Rossos of Carlos Sainz Jr and Pierre Gasly.
Neither Toro Rosso driver found time on their second Q2 runs, and Gasly ended up qualifying just 0.156s behind Sainz for his F1 debut, though by lapping slower than he managed in Q1.
Haas team-mates Romain Grosjean and Kevin Magnussen failed to make it through to Q2, by more than three tenths of a second, as faster rivals made late improvements and knocked them into the drop zone.
Pascal Wehrlein got his Sauber to within half a tenth of a second of beating Magnussen to 17th place on the grid.
Marcus Ericsson was almost half a second slower in the second Sauber and slowest of those to set a time.
Malaysian GP grid
|3||Max Verstappen||Red Bull/Renault||1m30.541s||0.465s|
|4||Daniel Ricciardo||Red Bull/Renault||1m30.595s||0.519s|
|6||Esteban Ocon||Force India/Mercedes||1m31.478s||1.402s|
|9||Sergio Perez||Force India/Mercedes||1m31.658s||1.582s|
|14||Carlos Sainz Jr.||Toro Rosso/Renault||1m32.402s||2.326s|
|15||Pierre Gasly||Toro Rosso/Renault||1m32.558s||2.482s|