Lewis Hamilton took a sensational victory in a thrilling, rain-hit German Grand Prix as Ferrari's Sebastian Vettel crashed out to gift the Mercedes driver a 17-point lead in their championship battle.
Vettel had been cruising to victory ahead of Hamilton's team-mate Valtteri Bottas until rain started to fall with about 25 laps to go.
The downpour, affecting only part of the track, turned the race on its head and brought Hamilton into the mix when he had been looking at a fourth-place finish after starting 14th following a hydraulic failure in qualifying.
Hamilton began to carve into the advantage of the three leading drivers - Vettel, his Ferrari team-mate Kimi Raikkonen and Bottas - as chaos erupted down the field.
And then, as the rain became heavier, Vettel lost control at the Sachs Kurve hairpin in Hockenheim's Stadium section in front of tens of thousands of his home fans, bringing out the safety car.
The four-time champion swore over the radio as he took in the potential damage to his title hopes.
Hamilton pulled away at the front following the safety car period, but only after Bottas was told to back off an initial challenge and hold position.
Behind the Mercedes one-two, Raikkonen took third while Max Verstappen was fourth for Red Bull despite making two pit stops to change tyres in three laps amid the confusion caused by the rain.
It was a remarkable result in a remarkable race, which had started as a damage-limitation exercise and ended with Hamilton's 66th career victory - and one of his best.
"Get in there, Lewis," his engineer Peter Bonnington said as the chequered flag fell. "Miracles do happen."
"Great job by you guys," Hamilton said, but it had been far from smooth sailing for the world champion.
Hamilton's win was later put in doubt after he was summoned to the stewards to explain a driving misdemeanour but he escaped with a reprimand.
- Reaction to a dramatic race at Hockenheim
- 'Vettel's binned it!' - listen to the moment of Ferrari driver's crash
- Chequered Flag podcast: Hamilton reigns supreme amid chaotic race
How did he do that?
The race was thrown into disarray by the rain and Mercedes were not immune from the chaos, as evidenced by a breathless radio exchange when the safety car was deployed following Vettel's crash.
Hamilton was told to pit, then told the team Raikkonen was pitting in front of him and was told to stay out, which became "in, in, in, in!" as he aborted and cut across the grass to rejoin the track.
"Hey, man," Hamilton said, expressing his opinion he could do without that sort of confusion.
"Just go for it," Bonnington replied.
Hamilton's 219th career race was remarkable in a number of different ways.
He made his soft tyres last 42 laps even as he carved through the field, and Mercedes decided to pit him for the softest ultra-soft tyres even though they knew rain was imminent.
The team gambled on the rain only hitting part of the track and not getting too heavy, and they were exactly right. Many backmarkers gambled on wet tyres but the leading runners all stayed out, and Hamilton began to gain on the three men in front of him.
It looked at one point as if he had the pace to win even if the rain got any worse - but it did not.
Vettel was trying to maintain his lead and was pulling away from Raikkonen with 15 laps to go.
But then, two laps later, as the rain spread across more of the track, Vettel slithered slightly wide on entry to the Stadium hairpin and could not keep the car on track.
He slowly hit the barrier on the exit and punched his steering wheel in dismay, knowing this was a potentially decisive moment in the title race of his own making.
"I don't think it was a huge mistake," Vettel said. "It's not like I will have huge difficulties sleeping because I made a big mistake. We didn't need the rain.
"We have a strong car, so we can be as confident, more confident, than anybody else. It was one of those moments. My mistake. Apologies to the team.
"Small mistake, big disappointment. The tyres weren't fresh, but it was slippery for everyone."
Mercedes and Ferrari issue team orders
After Vettel's crash, Hamilton was leading behind the safety car from Bottas and Raikkonen but had tyres that were 10 laps older.
Bottas challenged him from the restart with nine laps to go, but Hamilton held him off, began to extend his lead and the Finn was told to "hold position" by chief strategist James Vowles.
"We had a bit of a battle on lap one after the safety car with Lewis," Bottas said. "I didn't get past then and they told me to minimise the risk, which I understand."
There was a team orders incident at Ferrari, too.
Although Vettel dominated from the start, he ended up behind Raikkonen after their pit stops had finished as a result of the Finn coming in much earlier.
Vettel sat behind his team-mate but began to complain over the radio that he was being held up and destroying his tyres, saying the situation was "silly".
Eventually, after eight laps, chief engineer Jock Clear came on the radio, and asked Raikkonen "not to hold up Sebastian".
Raikkonen came back at him and asked what he meant, and eventually said: "Do you want me to let him go? Just tell me."
Vettel went through but there will be questions as to why it took Ferrari so long to make the obvious call.
Full exchange between Raikkonen and the team:
Ferrari's senior performance engineer Jock Clear: "Kimi, this is Jock. You're aware we need to look after tyres. Both cars need to look after tyres and you two are on different strategies. We'd like you not to hold up Seb. Thank you."
Raikkonen: "I'm sorry but can you be direct? What do you want?"
Clear: "Losing as little time as possible where you can, obviously, but Seb is capable of going quicker. He's hurting his tyres and you are as well. We need to look after them."
Raikkonen: "So you want me to... let him go? Please. Just tell me."
Driver of the day - Lewis Hamilton
The first part of the F1 season ends in Hungary next weekend, where the twisty track could bring Red Bull into the fight for victory, and should favour Ferrari over Mercedes. But, after a race like this, who would dare predict a result?