Sebastian Vettel, victor in Australia and last year in Bahrain, was fifth quickest ahead of last year's pole-sitter Valtteri Bottas who was sixth for Mercedes.
Vettel, who has 25 points to Hamilton's 18 in this year's title race between the two four-times champions, took pole position for his 200th race on Saturday ahead of his Ferrari team-mate Kimi Raikkonen.
Red Bull'sDaniel Ricciardo put in a scorcher of a lap to be fifth and just a few tenths off the pace from Hamilton, showing how fast his auto is this season.
The Red Bullers are not sleeping either and although Verstappen is favoured, Daniel Ricciardo is more than capable of pulling it out of the hat.
Lewis Hamilton didn't make progress off the line and was actually passed at the end of the first lap by a fast-starting Max Verstappen, who had began in 15th.
Verstappen's auto lost power and stopped on the track in the first session.
Ferrari identified a small electrical fault with Vettel's auto after FP3, but he was ready to go again in time for qualifying under the lights at the Bahrain International Circuit.
Mercedes technical director James Allison said after Friday practice that the team were not as competitive in relation to Ferrari as they had been in Melbourne.
In a boost for Ferrari, both Mercedes cars were more than half a second slower than the best lap set by Raikkonen, who was investigated by race stewards for an unsafe auto release following a pitstop.
The injured mechanic has been taken to hospital for treatment.
Vettel had led from pole position, with Bottas slotting into second place at the start from third on the grid, but ended up having to battle the Mercedes pair alone.
Following a pit stop, the Ferraridriver mistakenly made contact with a member of his team.
Toro Rosso'sPierre Gasly impressed with a time that was sixth fastest, and will start the Bahrain GP fifth on the grid thanks to Hamilton's penalty.
Hamilton eased into the final part of qualifying, looking more comfortable on the slower soft tyre to go second.
In the lead, Hamilton was 5.3 seconds clear of Vettel after 22 laps, an advantage trimmed to half a second by lap 25 with Bottas five seconds adrift in third.
Sauber's Marcus Ericsson banked his first points since the 2015 Italian Grand Prix in ninth place after running an extremely long first stint on softs and switching to mediums to execute a one-stop strategy to good effect.