Jenson Button marked his 200th Grand Prix in perfect style with a well-judged victory in ever-changing conditions.
Team mate Lewis Hamilton led much of the race but a poor tyre call and a drive-through penalty left him off the podium.
That left Sebastian Vettel in second place with an increased championship lead.
Hamilton takes the lead from Vettel
A series of showers before the race meant the whole field started on intermediate tyres on a damp track.
Vettel kept his lead at the start while the two McLarens ran wheel-to-wheel for the first corner, Hamilton coming out ahead.
The McLaren driver pressed him hard through the opening laps, trying on the inside and outside at turn two. Vettel eventually ran wide at the corner and Hamilton was through, instantly pulling out a 2.5 second lead.
Alonso fights his way forward
The Ferrari drivers struggled for traction at turn one and slipped behind the Mercedes pair. Fernando Alonso tried to find a way around the outside of Michael Schumacher on the first lap, eventually getting him at the final corner.
Alonso quickly caught and passed Nico Rosberg as well, but understeered onto the run-off at turn two shortly afterwards, handing the position back.
He set about reeling the Mercedes in again but ran wide a second time, this time at turn 12, falling behind Felipe Massa.
His team mate offered little resistance and Alonso took the place back with ease. Soon he was back on Rosberg’s tail and used the DRS to fly past on the straight.
Shortly before that, Massa ran wide at turn two, placing his wheels on the treacherous wet white line. The Ferrari snapped sideways and Massa skidded backwards into the barrier. The impact was only slight but enough to break part of his rear wing endplate.
Webber wins in switch to slicks
Mark Webber made an early switch to slick tyres. He set the fastest sector time in his out-lap shortly afterwards, showing his change had been well-timed. Massa came in on the same lap, and the other cars quickly followed suit.
Hamilton and Vettel came in on the same lap, the McLaren emerging behind Schumacher, who was yet to stop. Hamilton was briefly held up until Schumacher pitted at the end of the lap.
Button had changed to super-soft tyres one lap before Vettel and was quickly up to speed. He caught Vettel and dived down the inside of the Red Bull for second at turn two.
Further back Webber did exactly the same to Alonso, grabbing fourth place with superior traction as he came out of turn one. On the next lap Webber ran wide at the first corner, but had already pulled enough of a gap over Alonso to keep the place.
Hamilton stretched his legs, building up a lead of 8.6 seconds over his team mate. But towards the end of the stint Button began to catch him again – a tremendous battle was brewing between the two of them.
Hamilton stayed ahead after the front runners took on fresh sets of super-soft tyres. Webber was gradually catching Vettel but Alonso was growing tired of starting at the Red Bull’s rear wing.
He made an early third stop for another set of super-soft tyres which left his rivals wondering how to react. With Alonso back out on soft tyres, lapping over two seconds faster than Hamilton, the leading quartet decided they had to react.
Hamilton took a further set of super-softs while Button and the two Red Bull drivers plumped for softs.
Getting the soft tyres to the end of the race without a further stop looked like a stretch at this point, while Hamilton and Alonso would definitely have to stop again. But a change in the weather meant we wouldn’t discover who got this call right.
Hamilton spins a win away
Fresh rainfall hit the track on lap 47 as Hamilton spun at the chicane. It cost him the lead to Button, but the damage to his race was far greater than that.
Hamilton flicked his car around as Paul di Resta arrived on the scene, and took to the grass as the McLaren skidded in front of him. The stewards took a dim view of Hamilton’s mve and handed him a drive-through penalty.
In the meantime the McLarens scrapped furiously for the lead as the rain began to fall even harder. First Button slithered off at turn two and Hamilton took the lead back.
Then Hamilton ran wide at the final corner and Button took him as they headed into turn one. But at the very next corner Button went wide again and Hamilton was back through into the lead.
While all this was going on the McLaren drivers were in discussion with the pit wall on whether to switch to intermediate tyres. Initially, the team told both to come in which would have meant Button queueing behind Hamilton.
But as the lap neared an end the team decided not to bring Button in. Hamilton, struggling to hear his instructions with a faulty radio, did pit for intermediate tyres, which proved to be a crucial error.
He was not alone in making the mistake. Webber also switched to intermediates and, like Hamilton, had to return for more slick tyres. Hamilton was further delayed by his drive-through penalty, and ended up behind Webber in sixth.
Hamilton squeezes past Webber
Button and Vettel survived the rain shower on their soft tyres. Alonso appeared in third, despite needing another pit stop for soft tyres and spinning off again at turn 12. That might have kept him from catching Vettel, who also went off at turn two during the rain shower.
Massa held fourth until the recovering Webber and Hamilton arrived on his tail. Webber blasted past with his DRS open on lap 58, and Hamilton followed him through at the chicane. Massa came in for his fourth and final pit stop soon afterwards.
Hamilton kept up his pursuit of Webber and was well-placed to take advantage of the clutch of traffic they caught on lap 64. Facing the classic problem of lapping cars that were busy passing each other, Webber was held up by Kamui Kobayashi at turn 11, and Hamilton pounced, squeezing down the inside at turn 12.
Webber kept Hamilton in sight over the closing laps but wasn’t able to take his place back and that was how they finished, with Massa in sixth place.
Di Resta claimed ‘best of the rest’ honours with seventh, one lap down, after passing Kobayashi late in the race. Sebastien Buemi also took the Sauber for eighth place having started 23rd.
But team mate Jaime Alguersuari’s attempt to follow him past the Sauber ended in contact. That left the other Toro Rosso tenth, one place behind Nico Rosberg, another driver who switched to intermediate tyres late on.
Kobayashi abandoned his attempt to finish the race with just two pit stops and recovered to take 11th ahead of Vitaly Petrov, who finished where he started.
He had a better race than team mate Nick Heidfeld who spent the early part of the race stuck behind Heikki Kovalainen and Adrian Sutil. His Renault caught fire in the pits and he drove the smouldering car out onto the track.
In similar scenes to his fire during practice in Barcelona, Heidfeld leapt from his car as the left-hand sidepod became engulfed in fire. There was even a small explosion as the marshals brought the conflagration under control.
Rubens Barrichello finished 13th for Williams ahead of Sutil, who went off at the chicane on the first lap, and Perez, who fell from tenth to 20th on lap one. The other Williams of Pastor Maldonado was 16th following a drive-through penalty for pit lane speeding.
Timo Glock brought his Virgin home 17th in front of Daniel Ricciardo. The HRT driver led Jerome D’Ambrosio and Vitantonio Liuzzi home in his third race.
Schumacher retired shortly after spinning while being passed by Massa, and both Lotuses dropped out during the race.
A jubilant Button crossed the line to record his second victory of the year in his milestone race. But second place for Vettel increases his championship advantage to 85 points.
In the absence of a consistent championship rival, it is a lead which will surely prove unassailable.
2011 Hungarian Grand Prix
Image © McLaren