Lewis Hamilton will start the Bahrain Grand Prix from pole position after producing an impressive late effort to edge Mercedes team-mate Nico Rosberg in qualifying.
The reigning world champion was made to work hard for the 51st pole of his career after making an error on his penultimate run.
However, Hamilton recovered from the mistake to post a 1:29.493s effort on his final lap to pip Rosberg by just 0.077s.
The pole position was in doubt shortly after the session when the Brit was called to the stewards following a pitlane incident.
Hamilton reversed in the pit lane while finding the correct place to park his car after the session.
Officials issued a reprimand but allowed Hamilton to keep his pole position.
The controversial elimination qualifying once again failed to deliver its desired results highlighted by several periods without any cars on track.
Ferrari appeared to have the pace to challenge Mercedes in qualifying but in the end Sebastian Vettel and Kimi Raikkonen wound up third and fourth.
Four-time world champion Vettel was more than half a second slower than Hamilton.
Daniel Ricciardo emerged as the best of the rest in fifth, while his Red Bull team-mate Daniil Kvyat struggled after being the first eliminated in Q2.
“I don’t think we expected to be fifth,” said Ricciardo.
“To be fifth now is like a pole because I don’t think we’re on the pace of Mercedes and Ferrari so it’s really good.”
Williams drivers Valtteri Bottas and Felipe Massa were sixth and seventh respectively with Nick Hulkenberg eighth fastest.
Haas F1 continued to impress with Romain Grosjean clocking a time good enough for ninth ahead of the Toro Rosso duo of Max Verstappen and Carlos Sainz.
McLaren reserve driver Stoffel Vandoorne showed his class by out-qualifying his more experienced team-mate Jenson Button to secure 12th on the grid.
Button was less than a tenth slower than the GP2 champion in 14th behind Esteban Gutierrez while in front of Kvyat.
Pascal Wehrlein will start from 16th in the Manor ahead of Marcus Ericsson, Sergio Perez and Jolyon Palmer.
Rio Haryanto and Felipe Nasr were eliminated early in Q1 along with Kevin Magnussen, who will start from pit lane after failing to stop for a weight check at the end of Practice 2.
Result: Formula 1 Bahrain Grand Prix Qualifying
|5||Daniel Ricciardo||Red Bull/TAG Heuer||1:30.854s||+1.361s|
|8||Nico Hulkenberg||Force India/Mercedes||1:31.620s||+2.127s|
|10||Max Verstappen||Toro Rosso/Ferrari||1:31.772s||Q2|
|11||Carlos Sainz||Toro Rosso/Ferrari||1:31.816s||Q2|
|15||Daniil Kvyat||Red Bull/TAG Heuer||1:32.241s||Q2|
|18||Sergio Perez||Force India/Mercedes||1:32.911s||Q1|