HOCKENHEIM, Germany — Lewis Hamilton regained the Formula One championship lead in unexpected and dramatic fashion on Sunday, winning the German Grand Prix after race leader Sebastian Vettel crashed and then surviving an investigation into his own driving.

Hamilton was summoned to speak to stewards to explain a move late in the race, where he went to the pits and then aborted his move. He escaped with a reprimand and so kept his win, his fourth this season and 66th overall.

"It's been the most emotional day, up and down. No one ever wants to go see the stewards because they have the hardest job," a relieved Hamilton said. "I was just 100 per cent open with them. They could see how confusing it was."

The incident came while the safety car was deployed following Vettel's sudden crash. Hamilton decided against pitting at the last second and crossed the grass to rejoin the track — which is prohibited.

"I just slowed down and trundled over some grass, and tried to join the track as safely as I could," said Hamilton, who finished ahead of Mercedes teammate Valtteri Bottas.

Governing body FIA said it cleared Hamilton — who faced a 5-second time penalty which would have handed Bottas the victory — because "driver and the team candidly admitted the mistake" and "at no time was there any danger to any other competitor."

Earlier, heavy rain played havoc at the Hockenheimring as Vettel misjudged a basic entry into a turn and slid over the gravel into the barriers with 15 laps to go.

The four-time Formula One champion started from pole position and seemed in control. He kicked the gravel in frustration as he stepped out his car.

"I threw it away. It was my mistake," Vettel said. "I was a tiny bit too late on the brakes, locked the rears and I couldn't turn. It wasn't the biggest mistake I've done, but one of the most costly ones."

His mishap opened the door wide open for Hamilton, who is 17 points clear of Vettel after trailing by eight beforehand.

The British driver was fourth at the time of Vettel's sudden lapse, having started from 14th on the grid because of a hydraulic problem in qualifying.

"You've always got to believe," said Hamilton, adding defiantly: "For those who don't know me, now you do."

Bottas started and finished second, with Kimi Raikkonen taking third for Ferrari. Lance Stroll of Montreal did not finish after starting in 17th.

Red Bull driver Max Verstappen was fourth for Red Bull, but teammate Daniel Ricciardo retired after rising from last on the grid to seventh.

Vettel's incident led to a safety car coming out for several laps, prompting confusion at Mercedes.

Hamilton was told to come into the pits, but ignored his mechanic screaming "In, in, in, in!" at him.

"They were all panicking in the pit wall," said Hamilton, who started to move into the pit lane before doubling back and landing himself in trouble with stewards.

"It was the most confusing thing," Hamilton said, recounting his team's orders. "They were shouting 'No, (go) left! No, (go) right!"

When the race resumed, with about 10 laps left, Bottas almost overtook Hamilton.

Shortly after, Bottas was firmly told on team radio to "hold position" and not challenge Hamilton.

"Taking positives as a team, perfect result for us," said Bottas, who added — seemingly half-heartedly — that he "understood" the call.

Ferrari made a call, too, at Raikkonen's expense.

With a little more than 20 of the 67 laps to go, he was leading Vettel, who complained of his tires overheating.

Ferrari's senior performance engineer, Jock Clear, told Raikkonen not to hold up Vettel.

Raikkonen replied: "I'm sorry but can you be direct? What do you want?" After another indirect message, Raikkonen added "So you want me to let him (past)? Please. Just tell me."

He eventually did, ending the Finnish driver's hopes of a first win since the season-opening Australian GP in 2013.

Asked about the instructions, Raikkonen said "it wasn't clear, I had the speed."

Hamilton's win moved him level with F1 great Michael Schumacher on four German GP wins.

Vettel had won once before in Germany — at the Nuerburgring — but has never won at Hockenheim. He grew up less than 30 minutes away, in Heppenheim, and may never get a better chance amid doubts over future F1 races.

The German GP turned the tables on Ferrari, which also conceded top spot to Mercedes in the constructors' championship.

Things started well, though, with Vettel getting away cleanly and setting fastest laps

Raikkonen was the first of the front-runners to change tires, on Lap 15, coming out just ahead of Hamilton.

Losing speed, Hamilton changed tires on lap 43.

When he came back out, the heavy rain started falling.

Raikkonen lost position to Bottas, and Vettel lost control of the title race.

Vettel needs to bounce back strongly at the Hungarian GP next weekend, or Hamilton will take the momentum into the summer break.

___

More AP auto racing: https://racing.ap.org

___

Follow Jerome Pugmire on Twitter at https://twitter.com/jeromepugmire