Ferrari's Felipe Massa took pole for Sunday's Malaysian Grand Prix after a pulsating final lap in Sepang.
Massa made amends for a poor qualifying session in Melbourne
Massa made amends for his qualifying failure in Melbourne by clocking one minute 35.043 seconds, 0.267 secs ahead of world champion Fernando Alonso.
The McLaren driver split the Ferraris, with Kimi Raikkonen claiming third.
Lewis Hamilton led the British pack by taking fourth in the second McLaren, with David Coulthard 13th, Jenson Button 15th and Anthony Davidson 18th.
Renault, who won the last two Grands Prix in Malaysia, endured another disappointing day with Heikki Kovalainen 11th and, last year's winner, Giancarlo Fisichella 12th.
Massa qualified 16th at the opening Australian Grand Prix because of a gearbox failure but started from the back of the grid after changing his engine. He did well on race day to recover sixth place.
We hope to have a good fight with Ferrari and complete the job
McLaren driver Fernando Alonso
This time the Brazilian, who led both of Friday's practices, is expecting to be at the heart of another tight contest between the Ferraris and the McLarens.
"Melbourne didn't finish as I expected but things look a little bit different here," said Massa. "It was a great final lap and I tried to do everything that I could.
"McLaren were strong in qualifying and they will make us work harder for a good race tomorrow. Hopefully, I can fight very hard from the beginning to the end."
Alonso, who lines up on the front row alongside Massa, is confident McLaren will be even stronger than in Melbourne, where he took second ahead of team-mate Hamilton.
"This week we have improved the car and have a much more competitive package," said Alonso.
"Realistically our pace is not as good as the Ferraris but we hope to have a good fight with them and complete the job tomorrow. Everything seems to be going in the right direction.
Hamilton, who claimed fourth on the grid with an assured drive in Sepang, was also satisfied ahead of Sunday's race.
"It went pretty smoothly, I think the car performed well and we look forward to the race," said Hamilton, 22.
"I'm optimistic about the race and I'm on the clean side of the track."
Grid positions for Malaysian Grand Prix:
1 Felipe Massa (Bra) Ferrari 1min 35.043secs
2 Fernando Alonso (Spa) McLaren 1:35.310
3 Kimi Raikkonen (Fin) Ferrari 1:35.479
4 Lewis Hamilton (Gbr) McLaren 1:36.045
5 Nick Heidfeld (Ger) BMW Sauber 1:36.543
6 Nico Rosberg (Ger) Williams 1:36.829
7 Robert Kubica (Pol) BMW Sauber 1:36.896
8 Jarno Trulli (Ita) Toyota 1:36.902
9 Ralf Schumacher (Ger) Toyota 1:37.078
10 Mark Webber (Aus) Red Bull 1:37.345
11 Heikki Kovalainen (Fin) Renault 1:35.630
12 Giancarlo Fisichella (Ita) Renault 1:35.706
13 David Coulthard (Gbr) Red Bull 1:35.766
14 Takuma Sato (Jpn) Super Aguri 1:35.945
15 Jenson Button (Gbr) Honda 1:36.088
16 Vitantonio Liuzzi (Ita) Scuderia Toro Rosso 1:36.145
17 Scott Speed USA Scuderia Toro Rosso 1:36.578
18 Anthony Davidson (Gbr) Super Aguri 1:36.816
19 Rubens Barrichello (Bra) Honda 1:36.827
20 Alexander Wurz (Aut) Williams 1:37.326
21 Christijan Albers (Ned) Spyker 1:38.279
22 Adrian Sutil (Ger) Spyker 1:38.415
Follow live coverage of the race from 0700 GMT on Sunday on the BBC Sport website and Radio Five Live