World champion Sebastian Vettel took his and Red Bull's first pole position of 2012 ahead of McLaren's Lewis Hamilton at the Bahrain Grand Prix.
The German, who out-qualified team-mate Mark Webber for the first time this year, was 0.098 seconds quicker than Hamilton, with Webber third.
McLaren's Jenson Button was fourth, ahead of Mercedes' Nico Rosberg.
Ferrari's Fernando Alonso and Force India's Paul di Resta did not set a time and are ninth and 10th.
Both men preferred to save a set of tyres for the race because tyre life is expected to be a critical factor.
The same reason lies behind Lotus driver Kimi Raikkonen, whose team-mate Romain Grosjean is seventh, failing to make it into the top 10.
Raikkonen said he "could easily" have got into final qualifying but preferred to save a set of tyres for the race.
The chief beneficiary of all this strategic play was Toro Rosso's Daniel Ricciardo, who qualified a stunning sixth, ahead of Grosjean and Sauber's Sergio Perez.
Rosberg's team-mate Michael Schumacher will start 17th after failing to get out of the first qualifying session.
Vettel has had a difficult start to the season, uncomfortable in Red Bull's new car, and before Bahrain his highest qualifying position was fifth.
But Red Bull's race pace has been strong and Vettel said he was optimistic of a good result in the grand prix.
"We should be better off in the race," he said. "Our race pace has proven to be consistent in the last couple of races.
"I'm happier with the way the car feels. We should be able to get the same kind of feeling and result on Sunday.
"I'm looking forward to the start and then I think it will be very tight. I think Nico [Rosberg] has been very strong all weekend and the Lotus guys can surprise.
"In terms of race pace, I think everyone will be much closer together."
Vettel said his pole owed much to intense work by the team to understand better the car.
"We have been busy working on the car," he said, "trying to find the perfect solution and the right way to go forward. I don't think the boys had much sleep the last four races.
"It's very good to put the car on pole. The car felt much better all weekend. I was quite happy. It wasn't a smooth qualifying for us, nearly out in Q1, nearly out in Q2. It's great that we could beat Lewis."
Hamilton was happy with his second place, despite losing out to the German: "I'm definitely very happy with the job we've done, and the improved set-up.
"It was a bit close in Q1, but thank goodness we got through. It was probably our best qualifying session. We've just got to keep on pushing."
Webber, however, was surprised to have been in the top three. "Seb did a good lap. We are happy to be towards the front, after there was a big gap on Friday in particular. We are pretty surprised."
Schumacher was knocked out of qualifying with the very last lap of the first session by Caterham driver Heikki Kovalainen.
Schumacher revealed that his DRS rear-wing overtaking aid, which boosts straight-line speed and of which use is free in qualifying, had failed.
"There was no need to go out again until it was fixed and then the time ran out," he said.
Kimi Raikkonen failed to make it into the top 10, and will start 11th, after team-mate Grosjean displaced him in the final seconds of the second session.
Ricciardo, who finished a career-best sixth in qualifying, said: "It's not always you have a day like this, so I can enjoy the moment, bearing in mind that it's Sunday that counts."
The controversy over the wisdom of racing in Bahrain in the middle of ongoing civil unrest continues to overshadow the weekend.
Jean Todt, the president of motorsport's governing body, has defended the decision to hold the race. His comments come after a protester was shot dead in clashes with riot police on Friday night in Bahrain.
The atmosphere in the paddock is muted in the wake of representatives of the Force India and Sauber teams encountering trouble on their way back from the track into the capital Manama on two different days leading up to the weekend.
Force India skipped the second practice session on Friday to ensure their staff could return from the circuit before dark, a decision made after F1 commercial boss Bernie Ecclestone offered to stay with them as late as they wished and accompany them back to their hotel, either with or without a police escort.
Force India's cars did not appear on television coverage of qualifying on Saturday.
BBC Sports News correspondent Dan Roan reported that there was heavy security on the roads leading to the circuit as the Bahraini authorities attempt to ensure that unrest in the country does not affect their biggest international sporting event.