Lewis Hamilton staged a thrilling fightback to catch and pass Max Verstappen for victory in the Hungarian Grand Prix.
Hamilton's eighth win of the season puts a headlock on the championship after a tense race-long battle between the drivers and their strategists at the Mercedes and Red Bull teams.
Hamilton came very close to pulling off a brave move for the lead around the outside of the 150mph Turn Four.
But a gamble by Mercedes to make an extra pit stop gave Hamilton much faster tyres for the closing stages and he closed a 20-second deficit in less than 20 laps to pass Verstappen for the lead with three laps to go.
It puts Hamilton 62 points ahead in the championship with nine races to go - and a maximum of 234 points available. His sixth title is as good as won.
- Hungarian Grand Prix full race results
- Listen: "Hats off to the strategists, hats off to Lewis Hamilton"
- What happened to the woman who beat Hamilton in go-karts?
Stalemate - then a heart-stopping moment
It was a mouth-watering fight between the greatest driver of his generation, Hamilton, and the man who is emerging as the leader of the next, and the first time they had disputed a grand prix victory in such a way.
The two were in a race of their own, with the Ferraris more than a minute behind at the flag and Hamilton's team-mate Valtteri Bottas taken out of contention by a touch with Hamilton and then Ferrari's Charles Leclerc on the first lap, which broke the Finn's front wing.
There was stalemate between Verstappen and Hamilton in the first stint, after the Dutchman converted pole position into a lead at the first corner, and Hamilton moved into second by passing Bottas, who had qualified ahead, into the second corner.
But as the time for pit stops approached, Hamilton closed right in on Verstappen, forcing Red Bull into an early stop on lap 25 to ensure Mercedes did not do the same and 'under-cut' them into the lead.
Mercedes left Hamilton out for another six laps, hoping to benefit from fresher tyres at the end of the race.
Hamilton rejoined six seconds behind, but was on Verstappen's tail within four laps and attacking hard.
But the Hungaroring is a notoriously difficult track on which to overtake and Hamilton was forced to improvise.
On lap 38, he was closer than ever to Verstappen and after tracking him through Turns One, Two and Three, Hamilton tried a bold move around the outside of Turn Four.
It would have come off, but for a flick of oversteer in the middle of the corner and he ran into the run-off area, giving Verstappen some breathing space.
A gamble that paid off
After another 10 laps of closely following Verstappen, and conversations with the team about how hard passing was going to be, Mercedes took a risk.
They called Hamilton for fresh medium tyres on lap 48, with 22 to go, the idea being to come back at Verstappen with fresher tyres at the end of the race.
For a while, it looked like it would not work. Hamilton was 20 seconds adrift when he rejoined from the stop and in seven laps had only gained just over four seconds.
But with 13 laps to go, Hamilton started to turn on the pace and take chunks out of Verstappen's lead.
With 10 laps to go, Hamilton was 11 seconds behind, but five laps later he was on Verstappen's tail, and his closing speed was so superior that he swept easily into the lead around the outside of Turn One at the start of lap 67.
Where were the Ferraris?
The Ferraris were next best, but they were in a separate race, losing nearly a second a lap throughout the race.
Leclerc was in third for much of the race but while he went for a conventional strategy, Sebastian Vettel was never far behind and he ran long on his first stint and fitted soft tyres for his second stint, while Leclerc was on hards.
Vettel closed in gradually in the second stint and passed Leclerc for third with two laps to go.
McLaren's Carlos Sainz drove another excellent race to be best of the race in fifth, impressively beating the Red Bull of Pierre Gasly into sixth.
Alfa Romeo's Kimi Raikkonen was seventh, ahead of Bottas, who fought back also on a two-stop strategy after dropping to last following an early stop to replace his front wing.
Lando Norris took ninth in the second McLaren after being passed by Sainz at the start and delayed by a slow pit stop, and Anglo-Thai Alexander Albon passed the Racing Point of Sergio Perez for 10th in the closing laps to take the final point.
Driver of the day
What happens next?
F1 heads into its nearly four-week summer break before reconvening at the Belgian Grand Prix on the magnificent Spa-Francorchamps track on the first weekend on 1 September. Despite their poor performance in Hungary, Ferrari could well go there as favourites, given the prodigious straight-line speed of their car.
What they said
Hamilton: "I'm tired which is how it should be. I feel really grateful for the day and for the team for continuing to believe in me and push to the limits. We've been together seven years and it never gets old and it always feels brand new like a new win for us and if it was not for these guys and the guys back at the factory, it wouldn't be possible."
Verstappen: "We were just not fast enough. I tried everything I could on that hard tyre to stay alive. Still, second, fastest lap, a good weekend overall. Congrats to Lewis, he was pushing me really hard. I like that. Still a good weekend for us. We were just lacking a bit of grip. We tried a one-stop, they had the opportunity for two and that worked out well."
Vettel: "Obviously we had a sitting in P4 to lose. We stayed out long in the first stint and we hoped the softs would last at the end and they did. I'm happy to get some champagne now. We couldn't go the pace with these two and it's good now to get a break - everyone has been working really hard and we need to recharge our batteries."