Red Bull's Sebastian Vettel won a third consecutive world drivers' title by three points in the Brazilian GP.
In an incident-packed, rain-affected race, Vettel fought back to finish sixth after dropping to last on lap one following a collision.
His rival Fernando Alonso of Ferrari finished second, meaning he needed Vettel to be lower than seventh.
McLaren's Lewis Hamilton had led at lap 54 until he was hit by Force India's Nico Hulkenberg.
The German was trying to pass Hamilton for the lead with 27 laps to go but lost control on the slippery track and slid into the side of Hamilton's car.
Hulkenberg, driving the race of his career up to that point, was given a drive-through penalty and finished fifth, behind Alonso's team-mate Felipe Massa in third and Red Bull's Mark Webber in fourth.
Vettel becomes the youngest driver in history to win three world titles - at six years younger than Ayrton Senna. He is only the third driver to win three in succession.
"It is difficult to imagine what goes through my head now even for myself," Vettel said. "I am full of adrenaline and if you poke me now I wouldn't feel it.
"It was an incredible race. When you get turned around at Turn Four for no reason and it becomes like heading the wrong way down the M25 it is not the most comfortable feeling.
"I was lucky no-one hit me but the car was damaged and we lost a lot of speed, especially when it dried up. Fortunately it started to rain again and I felt so much happier.
"A lot of people tried to play dirty tricks [during the season], but we did not get distracted by that and kept going, and all the guys gave a big push right to the end."
A breathless and topsy-turvy race, with intermittent rain, created drama from the first lap.
Vettel made a bad start from fourth on the grid and at the fourth corner was first tagged from behind by Lotus's Kimi Raikkonen and then hit by Williams's Bruno Senna.
The impact knocked Vettel into a spin, and damaged the rear bodywork of his car, and he was last as he crossed the line at the end of lap one.
Alonso finished the first lap fifth, but seconds later passed Massa and Webber as they went three abreast into Turn One to take third.
In those positions, Alonso would have been champion, but Vettel set about recovering lost ground and by lap eight was remarkably up to sixth place, while Alonso had slipped behind Hulkenberg after running wide at Turn One on lap five.
Through a series of twists and turns at the front, including varying degrees of rain and a safety-car intervention, Vettel was always in control of the championship.
With 20 laps to go, Alonso was fourth behind Hamilton, Hulkenberg and Button, and Vettel seventh.
As rain began to fall harder, Hulkenberg closed on Hamilton and the two collided. So Hamilton's last race for McLaren ended in a retirement rather than a victory.
More pit stops were needed for the leaders to fit intermediate tyres as the rain intensified, after which Button led from Massa and Alonso, with Vettel seventh.
Massa let Alonso by into second on lap 62, and two laps later Michael Schumacher, driving the last race of his career, moved over for Vettel to rise into sixth place and make his grip on the title more secure.
In the closing laps, Vettel was repeatedly urged by his team to slow down, reminding him that his position was good enough to win the title.
And then in a final dramatic twist, Paul di Resta crashed his Force India coming up the straight on the penultimate lap and the race finished under the safety car, confirming Vettel as champion.
"I'm very proud of the team," said Alonso. "We lost the championship before today, not in Brazil, this is a sport after all. When you do something with your heart and do it 100% you have to be proud of yourself and your team and we'll try again next year."
Race winner Button said: "I want to congratulate the whole team. This is the perfect way to end the season. We have had ups and downs and to end on a high bodes well for 2013."
Ferrari sealed second in the constructors' championship, holding off McLaren while Caterham overtook Marussia for the lucrative 10th place in constructors when Vitaly Petrov overtook Charles Pic, who is driving for Caterham next year, on lap 65.
Final Brazilian GP top 10
1. Jenson Button - McLaren 1:45:22.656
2. Fernando Alonso - Ferrari +2.754
3. Felipe Massa - Ferrari +3.615
4. Mark Webber - Red Bull +4.936
5. Nico Hulkenberg - Force India +5.708
6. Sebastian Vettel - Red Bull +9.453
7. Michael Schumacher - Mercedes +11.907
8. Jean-Eric Vergne - Toro Rosso +28.653
9. Kamui Kobayashi - Sauber +31.250
10. Kimi Raikkonen - Lotus +1 lap
Final F1 Driver's Championship standings top 10
1. Sebastian Vettel - Red Bull 281
2. Fernando Alonso - Ferrari 278
3. Kimi Raikkonen - Lotus 207
4. Lewis Hamilton - McLaren 190
5. Jenson Button - McLaren 188
6. Mark Webber - Red Bull 179
7. Felipe Massa - Ferrari 122
8. Romain Grosjean - Lotus 96
9. Nico Rosberg - Mercedes 93
10 Sergio Perez - Sauber 66