Red Bull's Sebastian Vettel took pole for the Singapore Grand Prix after some self-imposed anxious moments as his rivals came close to his time.
Vettel has dominated all weekend under the lights of the demandingMarina Bay circuit at Formula 1's night race, but sat out the final minutes of the session.
He thought he had done enough after a fast early run and watched as Mercedes' Nico Rosberg closed to within 0.091secs.
"It was very close and it's not the best feeling when you stand there and watch," Vettel said.
Lotus's Romain Grosjean took third, ahead of Red Bull's Mark Webber and Mercedes driver Lewis Hamilton.Vettel's title rival Fernando Alonso could manage only seventh in his Ferrari.
Grosjean's team-mate Kimi Raikkonen was knocked out in the second part of qualifying and will start 13th.
The Finn had to have a pain-killing injection in his lower back before qualifying after suffering pain from a muscle problem and was 0.701secs slower than Grosjean in the second part of qualifying.
"This morning I couldn't really try," said Raikkonen. "So we probably didn't get done what we wanted with the car but at least we got the car on the grid and we'll see what we can do tomorrow."
Vettel had looked set to take a crushing pole position by a significant margin after setting a time in the early part of the top 10 shoot-out which was 0.59secs quicker than Rosberg.
But although he told his team he felt he could improve by "a tenth or two" he was asked by engineer Guillaume Roquelin if he was happy not to run again and he said he was.
As his rivals began their runs on new 'super-soft' tyres at the end of the session, it became clear that it was going to be much closer than Vettel had thought.
Webber was matching his team-mate's time after two-thirds of the lap, only to lose 0.3secs in the final sector.
Grosjean set the fastest middle sector of all but could not quite match Vettel in the final sector, and Rosberg was close throughout his lap.
Mercedes team boss Ross Brawn told Rosberg over the radio: "He didn't run and I would think he was watching your lap getting somewhat anxious."
"I was watching the sector times closely," added Vettel. "Mark set a purple [fastest of all] sector one, Romain set a purple sector two, then Nico set a purple sector two, but fortunately my last sector was strong enough."
Ferrari have struggled with a lack of grip all weekend and Alonso ended up being out-qualified by team-mate Felipe Massa for the second consecutive race, despite being considerably faster throughout the weekend until the final qualifying runs.Massa has a point to prove following Ferrari's decision to drop him at the end of the year in favour of Raikkonen.
The top 10 was completed by McLaren's Jenson Button in eighth, Toro Rosso's Daniel Ricciardo and Sauber's Esteban Gutierrez.
Force India's Paul Di Resta was knocked out in the first part of qualifying for the fourth time in the last eight races and will line up 17th.
The Scot was 0.161secs slower than team-mate Adrian Sutil, who managed to scrape through in 15th place as the team continue to struggle on the new-specification tyre that was introduced at theHungarian Grand Prix four races ago.
"We're too slow on one lap," Di Resta said. "I've struggled a bit more than Adrian over one lap but I'm much stronger on a long run, so perhaps we've concentrated on that too much.
"But we've become vulnerable in Q1 and that's not good."
There was an impressive performance from Englishman Max Chilton, who was just 0.1secs behind Marussia team-mate Jules Bianchi as he continues to adapt to F1 in his rookie season.