By Andrew Benson
Ferrari's Kimi Raikkonen edged a thrilling qualifying session to take pole for Sunday's Belgian Grand Prix.
Raikkonen is 18 points behind Hamilton in the drivers' standings
The Finn's lap of one minute 45.994 seconds was just 0.017secs clear of team-mate Felipe Massa, with McLaren's Fernando Alonso 0.080secs further back.
Alonso's team-mate Lewis Hamilton was fourth fastest but 0.395secs adrift of the reigning world champion.
BMW Sauber's Robert Kubica was fifth but drops to 14th on the grid after being forced to change his engine.
Renault's Giancarlo Fisichella suffered a similar fate and will start from last place.
Scot David Coulthard was 13th fastest in his Red Bull, just ahead of English Honda driver Jenson Button.
It is a proper circuit for F1 cars, long corners and very flowing. I like it and it is good for me
The leading positions set the stage for a classic battle in Sunday's race at the end of one of the most dramatic Grand Prix weekends in recent years.
The on-track action has been overshadowed by the fall-out from the spy scandal that has seen McLaren thrown out of this year's constructors' championship and fined £49.2m for possessing confidential Ferrari information.
But the times in qualifying were much closer than had been suggested in the morning's final practice session, when Ferrari were well ahead of McLaren.
Raikkonen has appeared the likely pole winner throughout the day, but McLaren - or Alonso at least - are much closer to the Ferraris on pace than had been expected.
At one stage it had appeared as if Alonso had cracked under the strain of what must have been an extremely taxing weekend for the Spaniard.
The double world champion spun at the Rivage hairpin on his first flying lap, so the pressure was intensified as he and his three main rivals started their final runs.
But he responded in style, pushing Hamilton down to fourth, and coming close to joining Raikkonen on the front row.
Alonso said: "We are quite confident for the race. We knew Spa was maybe a little bit more like Turkey, where Ferrari were very strong, and we expected them to be strong and fighting for the win here.
We have made some improvements and we expect to be stronger in the race
"We don't know if we can fight for the win, but we hope it will be closer than in Turkey."
The two McLaren drivers head into the race, which starts at 1300 BST on Sunday, with Hamilton just three points ahead of Alonso.
Raikkonen is their closest challenger, 18 points behind the Briton.
He is still suffering from a sore neck after his 180mph crash at Monza last weekend, but he said he is in shape to take what would be his third consecutive victory at Spa.
"The neck is OK," Raikkonen said. "It is not 100% right but it should be fine.
"The circuit is very challenging - a lot of people like it. It is a proper circuit for F1 cars, long corners and very flowing. I like it and it is good for me.
"We knew Monza would be a bit tricky for us and we expected to be strong here, but it is going to be close."
Hamilton was reasonably happy with his efforts but said his build-up to the race weekend had been affected by the 'spygate' scandal.
The Briton attended the World Motor Sport Council hearing in Paris even though he had not been called to give evidence.
"The week definitely affected me," he said.
"I had a couple of events, fly to a couple of different countries and then fly to Paris. It definitely didn't help but I felt it was important to go to support the team."
Final qualifying positions for Belgian Grand Prix:
1. Kimi Raikkonen (Fin) Ferrari 1 min 45.994 secs
2. Felipe Massa (Bra) Ferrari 1:46.011
3. Fernando Alonso (Spa) McLaren 1:46.091
4. Lewis Hamilton (GB) McLaren 1:46.406
5. Nico Rosberg (Ger) Williams - Toyota 1:47.334
6. Nick Heidfeld (Ger) BMW Sauber 1:47.409
7. Mark Webber (Aus) RedBull - Renault 1:47.524
8. Jarno Trulli (Ita) Toyota 1:47.798
9. Heikki Kovalainen (Fin) Renault 1:48.505
10. Ralf Schumacher (Ger) Toyota 1:46.618
11. David Coulthard (GB) RedBull - Renault 1:46.800
12. Jenson Button (Britain) Honda 1:46.955
13. Vitantonio Liuzzi (Ita) Toro Rosso - Ferrari 1:47.115
*14. Robert Kubica (Pol) BMW Sauber 1:46.996
15. Alexander Wurz (Austria) Williams - Toyota 1:47.394
16. Sebastian Vettel (Ger) Toro Rosso - Ferrari 1:47.581
17. Rubens Barrichello (Bra) Honda 1:47.954
18. Takuma Sato (Jap) Super Aguri - Honda 1:47.980
19. Adrian Sutil (Ger) Spyker - Ferrari 1:48.044
20. Anthony Davidson (GB) Super Aguri - Honda 1:48.199
21. Sakon Yamamoto (Jap) Spyker - Ferrari 1:49.577
*22. Giancarlo Fisichella (Ita) Renault 1:46.603
* Demoted following engine changes