Lewis Hamilton became the youngest world champion in Formula One history by the skin of his teeth after a nail-biting Brazilian Grand Prix.
The English McLaren driver's title rival Felipe Massa won the race in his Ferrari but Hamilton grabbed the fifth place he needed at the last corner.
A late-race rain shower looked set to rob Hamilton of the title after a stop for wet tyres dropped him to sixth.
But he passed Toyota's Timo Glock as they entered the pit straight.
Renault's Fernando Alonso, the previous youngest champion, was second ahead of Massa's team-mate Kimi Raikkonen and Toro Rosso's Sebastian Vettel.
Hamilton's success buries the ghosts of last year, when after a remarkable debut season he let slip a massive lead in the final two races and Raikkonen sneaked in to win the title.
Ultimately, there were no similar mistakes this time around - but as he entered the final lap Hamilton was not going to win the title. I thought do I have it? Do I have it? And when they told me I was ecstastic
He - like Massa - had stopped to change to wet tyres as the rain fell in the closing laps.
But while the Brazilian held on to his lead, Hamilton dropped to fifth place behind Glock - who stayed on dry tyres.
Hamilton then lost fifth place - which was the minimum he needed if the Brazilian won - when he was passed at the start of the penultimate lap by Vettel.
Hamilton tried hard to pass the German, but he could not get close enough to him and he would have thought he had lost the title until he came to the last two corners of the lap.
There, Glock - who had started the final lap 18 seconds ahead of Hamilton - was struggling badly on the now-slick track and the McLaren slipped passed the Toyota as it accelerated up the hill towards the finish line.
"It's pretty impossible to put into words," Hamilton said.
"I thought do I have it? Do I have it? And when they told me I was ecstastic." We need to be proud of our race and our championship but for sure I'm very emotional
It was heartbreaking for Massa, whose family were celebrating what they thought was his success for a few seconds until they realised what had happened.
"The race was just perfect," said Massa, who won one race more than Hamilton this year.
"We did everything fantastically in such difficult weather, the rain coming at the end.
"I'm so proud about the race and the team. I'm so proud about the people around about the people who support me.
Massa could not hold back the tears as he realised he had lost out at the death
"It was an emotional day for me. You get here and you've almost done everything perfect but we saw Lewis passing Glock again and that mixed emotion.
"Unfortunately we missed [out] by one point but that's racing.
"We need to be proud of our race and our championship. It's one more day of our life when I will learn a lot but for sure I'm very emotional."
The thrilling climax was a stark contrast to the rest of the race, which Hamilton had approached with the caution he felt was required to avoid mistakes.
The 23-year-old - watched from the sidelines by his girlfriend Nicole Scherzinger, singer with the Pussycat Dolls - went into the race knowing he only had to finish fifth even if Massa won his home event.
That luxury showed in the way in which he and his McLaren team approached the Grand Prix.
A shower of rain five minutes before the scheduled start introduced a random element that was exactly what Hamilton did not need.
Hamilton's girlfriend, the pop singer Nicole Scherzinger, watched him win
It caused a five-minute delay and shaped the entire race.
The heavy shower doused the track in the area of the pits and some of the corners, but other areas remained dry.
And with the sun shining as the race started, it was only a matter of time before drivers started to pit for dry tyres.
Hamilton and McLaren played it safe, leaving it as late as they could before coming in to change tyres.
Hamilton stopped a lap later than Massa on lap 11 - and two laps after Vettel and Alonso.
McLaren's decision was the right one in that it limited their risk, but it was not the best in terms of absolute pace.
Vettel and Alonso's early stops vaulted them up into second and third places behind Massa.
Hamilton, by contrast, was demoted from fourth to sixth behind Massa, Vettel, Alonso, Raikkonen and the Force India of Giancarlo Fisichella, who had changed to dry tyres as early as lap three.
McLaren were confident the required result was always within their grasp.
But that was reckoning without the unfolding drama ahead.
Hamilton did not pass Fisichella until lap 18, out-braking him in a brave move at the first corner on the still-slippery track.
That put Hamilton into the fifth place he needed, and he was promoted to fourth by the three-stop strategy chosen by Toro Rosso for Vettel in contrast to the two stops of the other leading teams.
Coulthard's final race ended unhappily with a first-lap crash
Hamilton was only a couple of seconds ahead of Vettel by the time the Toro Rosso had made its stop and he had to up his pace to hold his rival off.
And a late shower increased the anxiety for Hamilton as he sought to close out the championship.
Hamilton stopped for wet tyres on lap 66 - a decision that could have cost him the title.
It dropped him to fifth place behind Glock, with Vettel right behind him.
Vettel pushed Hamilton hard and passed him with two laps to go, leading to the nail-biting finish.
Brazilian Grand Prix result:
1. Felipe Massa (Brz) Ferrari one hour 34 minutes 11.435 seconds
2. Fernando Alonso (Spa) Renault 13.298 seconds behind
3. Kimi Raikkonen (Fin) Ferrari +16.235
4. Sebastian Vettel (Ger) Toro Rosso-Ferrari +38.011
5. Lewis Hamilton (GB) McLaren-Mercedes +38.907
6. Timo Glock (Ger) Toyota +44.368
7. Heikki Kovalainen (Fin) McLaren-Mercedes +55.074
8. Jarno Trulli (Ita) Toyota +1:08.463
9. Mark Webber (Aus) Red Bull-Renault +1:19.666
10. Nick Heidfeld (Ger) BMW Sauber one lap behind
11. Robert Kubica (Pol) BMW Sauber one lap
12. Nico Rosberg (Ger) Williams-Toyota one lap
13. Jenson Button (GB) Honda one lap
14. Sebastien Bourdais (Fra) Toro Rosso-Ferrari one lap
15. Rubens Barrichello (Brz) Honda one lap
16. Adrian Sutil (Ger) Force India-Ferrari two laps
17. Kazuki Nakajima (Jpn) Williams-Toyota two laps
18. Giancarlo Fisichella (Ita) Force India-Ferrari two laps
R Nelson Piquet (Brz) Renault 0 laps completed
R David Coulthard (GB) Red Bull-Renault 0 laps
Key: R = retired
Fastest Lap: Massa 1:13.736 on lap 36