Lewis Hamilton failed in his bid for perfection under the lights in Bahrain as he found himself outdone for the first time in qualifying this season by Mercedes team-mate Nico Rosberg.

After clinching victory in last Sunday's race in Malaysia, Hamilton proceeded to dominate all three practice sessions at the Bahrain International Circuit, with Rosberg forced to play second fiddle.

But come qualifying it was current championship leader Rosberg who took the spotlight by grabbing his first pole position since last May's Monaco Grand Prix, a run of 16 races.

As last man on track, Hamilton had the opportunity to pip Rosberg, who was ahead by a quarter of a second after the first run in the final 12-minute session.

But the 29-year-old locked up at one stage, ending his bid for a hat -trick of pole positions after taking top spot in Australia and again in Malaysia.

By way of explanation, Hamilton said: "My first lap was okay, but on the second I just locked up into turn one and didn't have another chance.

"You can't always get it right, but credit to Nico who did a great job. I'm happy for the team we're on the front row, and I'll try and do better in the race."

Despite Hamilton's dominance, Rosberg was consistently closing the gap in practice before finally catching up in qualifying.

Come the conclusion, the German was far from surprised he had taken pole for the fifth time in his Formula One career, and second in a row in Bahrain, which this season stages a night race for the first time as part of the circuit's 10th anniversary celebrations.

"It has just worked well through the weekend. I've been finding my way, making progress and getting through some issues," said Rosberg.

"And Lewis is always tough to beat. Everything needs to go right to be ahead, and here it worked out.

"So surprised? My mind is on pole when I go into qualifying, and that is what I'm going for, so no, I'm not surprised."

The best of the rest behind Mercedes' third successive all-front row was Red Bull's Daniel Ricciardo, however, the Australian faces a 10-place grid penalty following an unsafe release from a pit stop in Malaysia and will start 13th.

It means all those drivers from fourth to 13th will move up a place, spearheaded by Williams' Valtteri Bottas.

Behind third-on-the-grid Bottas will be Force India's Sergio Perez, followed by Ferrari's Kimi Raikkonen and Jenson Button in his McLaren.

One major surprise was that Sebastian Vettel failed to make the top 10 for the second time this season, and just a week after qualifying on the front row at Malaysia, with the four-times champion only 11th in his Red Bull.