Sebastian Vettel took pole position for the Bahrain Grand Prix followed by Ferrari teammate Kimi Raikkonen on Saturday.
World champion Lewis Hamilton could only manage fourth, and will start from ninth on Sunday after incurring a grid penalty.
Raikkonen looked like he was going to get his first pole since last year's Monaco GP, but Vettel beat his time right at the end of qualifying under floodlights to clinch his 51st pole.
"It was quite intense," Vettel said. "The car has been excellent all weekend."
Mercedes driver Valtteri Bottas was third.
"It's disappointing for us not to be on the front row," Bottas said.
Ferrari's evening got even better when Hamilton finished behind Bottas, his teammate. Hamilton's five-place grid penalty is because he needed a gearbox change on Friday.
"Hopefully Lewis can come back and put some pressure on these guys," Bottas said.
Drivers must use gearboxes for six consecutive races before being allowed a new one. Hamilton's problem was caused by a hydraulic leak sustained during the season-opening Australian GP two weeks ago.
Vettel, last year's championship runner-up, has a golden chance to extend his overall lead. The German driver won in Melbourne — his 48th career win and 100th podium — with Hamilton finishing second after his team made an error of judgment during Vettel's pitstop.
Daniel Ricciardo qualified fifth on Saturday but his Red Bull teammate Max Verstappen managed only 15th after crashing in Q1.
It was a clumsy error from the 20-year-old Verstappen.
Heading into turn 2, he slid sideways off and thudded into the crash barriers, the left front wheel of his car mangled. It has been a poor start to the season from Verstappen. He span his car after pushing too hard early on in Melbourne two weeks ago and finished sixth.
At the start of qualifying, Romain Grosjean (Haas), Lance Stroll and Sergey Sirotkin (both Williams), Marcus Ericsson and Charles Leclerc (both Sauber) were eliminated from Q1.
New Zealand driver Brendon Hartley complained about damage to his left front wing and soon find out why: he had hit a bird. He'd done enough to make it into Q2, however.
Hartley, Verstappen and Force India's Sergio Perez were then eliminated from Q2, along with Fernando Alonso and his McLaren teammate Stoffel Vandoorne.
It was a blow to McLaren, after both drivers finished the race in Melbourne in the top 10, with Alonso in fifth place.
McLaren entered the season with high hopes after switching to Renault engines, following three troublesome seasons with Honda. But Toro Rosso chose to work with the Japanese engine supplier and both of their drivers did better in qualifying than McLaren.
Earlier, Raikkonen posted the fastest time in the third and final practice.
Hamilton expressed his annoyance over team radio as he came into the pit lane after P3, saying spectators got too close to his Mercedes.
"Who were those people on the left-hand side?" the British driver said. "I was coming in at some speed, I could have killed them."
It was a frustrating day for Hamilton, who is vying with Vettel for a fifth world title to move level with Argentine great Juan Manuel Fangio.