Reigning world champion Fernando Alonso secured his first victory for McLaren as he claimed an emphatic win in the Malaysian Grand Prix at Sepang.
Alonso led home Hamilton for a McLaren one-two in Malaysia
Alonso climbed above Kimi Raikkonen in the title race, leading home Lewis Hamilton for a McLaren one-two and their first win since Japan in 2005.
Briton Hamilton, 22, held off a late charge from Ferrari's Raikkonen.
Pole-sitter Felipe Massa blew his chances when he slid off trying to pass Hamilton on lap six and finished fifth.
"It is absolutely fantastic and a wonderful surprise," said Alonso, who chalked up his first win since his victory in Japan for Renault last October.
"The team has done a lot of work on the car but we never expected to be that competitive."
Alonso had rounded Massa at the first turn and, in an audacious move, Hamilton rounded both Ferraris from fourth on the grid.
That was the most difficult race I have ever had
Massa, who had been fastest in practice and took pole, briefly passed Hamilton on lap three, but the British rookie came round the outside of his Ferrari to move back up to second.
Massa's challenge was ended for good when, allowing his frustration to get the better of him, he tried to move beyond Hamilton again but skidded onto the grass and slid back to fifth.
"I made a mistake," the Brazilian said. "I tried to attack Lewis but ended up in the gravel.
"It is not easy to overtake on this circuit but I knew I had to try and I cannot blame myself for trying."
Raikkonen's own early attempts to move up the field were thwarted, but the Finn delivered a thrilling finale to the race as he chased down Hamilton.
The Australian Grand Prix winner reduced the gap between his Ferrari and Hamilton to 0.8 seconds on the last lap but, despite running at a faster pace than the McLaren, he ran out of time as Hamilton nosed across the line in second.
"That was the most difficult race I have ever had," said Hamilton, 22.
Raikkonen could not quite close down Hamilton in Sepang
"I had Kimi hunting me down for most of the race. I can't explain how tough that was, it was getting hotter but I had to keep pushing and I made no mistakes."
Alonso and Hamilton's feat in Malaysia saw them complete McLaren's first one-two since the Brazilian Grand Prix in 2005.
Raikkonen had to settle for third which saw him slide two points behind Alonso in the drivers' standings.
"I was happy to get some points but disappointed at the end," said the Finn.
"All weekend we've had problems so it was just one of those weekends. I got close to Lewis but didn't have the same speed as Felipe and couldn't challenge him."
Nick Heidfeld claimed fourth place for the second race in a row after also benefiting from Massa's mistakes.
The German moved up the field after Massa's excursion on to the grass and drove steadily to again press home BMW Sauber's improvement this season.
There was also some welcome progress for the Renault team as Giancarlo Fisichella finished sixth with rookie Heikki Kovalainen winning his first point in eighth. Toyota's Jarno Trulli split the Renaults in seventh.
Williams had shown some impressive pace in Malaysia, and had both their drivers inside the top 10, before the team's reliability problems came back to haunt them when Nico Rosberg was forced to retire from seventh with smoke streaming from his car.
It was another dismal day for Honda as Rubens Barrichello finished 11th, one place ahead of British team-mate Jenson Button.
Super Aguri's Anthony Davidson took 16th while David Coulthard retired his Red Bull on lap 39 after informing his team that he was "not comfortable with the car".
Results from the Malaysian Grand Prix, Sepang:
1. Fernando Alonso (Spa) McLaren 1:32:14.930
2. Lewis Hamilton (GB) McLaren +00:17.557
3. Kimi Raikkonen (Fin) Ferrari 00:18.339
4. Nick Heidfeld (Ger) BMW Sauber 00:33.777
5. Felipe Massa (Bzl) Ferrari 00:36.705
6. Giancarlo Fisichella (Ita) Renault 01:05.638
7. Jarno Trulli (Ita) Toyota 01:10.132
8. Heikki Kovalainen (Fin) Renault 01:12.015
9. Alexander Wurz (Aus) Williams-Toyota 01:29.924
10. Mark Webber (Aus) RedBull-Renault 01:33.500
11. Rubens Barrichello (Bzl) Honda 1 lap
12. Jenson Button (GB) Honda 1 lap
13. Takuma Sato (Jap) Super Aguri-Honda 1 lap
14. Scott Speed (US) Toro Rosso-Ferrari 1 lap
15. Ralf Schumacher (Ger) Toyota 1 lap
16. Anthony Davidson (GB) Super Aguri-Honda 1 lap
17. Vitantonio Liuzzi (Ita) Toro Rosso-Ferrari 1 lap
18. Robert Kubica (Pol) BMW Sauber 1 lap
R. Nico Rosberg (Ger) Williams-Toyota 13 laps
R. David Coulthard (GB) RedBull-Renault 19 laps
R. Christijan Albers (Ned) Spyker-Ferrari 48 laps
R. Adrian Sutil (Ger) Spyker-Ferrari 56 laps
Key: R = retired
Fastest lap: Lewis Hamilton, 1:36.701, lap 22