HOCKENHEIM, Germany — With track temperatures uncomfortably high at the sweltering German Grand Prix on Friday, Ferrari made the best of the conditions by topping both practice sessions.

Charles Leclerc finished ahead of teammate Sebastian Vettel in the afternoon, when the Hockenheimring track thermometer hit 51 degrees Celsius (124 F), reversing their positions from the already scorching morning session.

Mercedes driver Lewis Hamilton was third in both sessions, while teammate Valtteri Bottas could improve from fifth to fourth.

"It was extremely hot. I can't remember the last time I drove in these conditions," said Bottas, who is Finnish. "The weather is going to be completely different tomorrow and on Sunday, with lower temperatures and a chance of rain. I actually hope for rain — it would be nice to drive in the wet."

Lance Stroll of Montreal was seventh.

Hamilton won the race in pouring rain last year, profiting after Vettel crashed while comfortably leading.

On Friday, the five-time F1 champion Hamilton also struggled to get the best out of his Mercedes.

"These tires don't like the temperature. They were always overheating, so that's been the main issue," the British driver said. "We're hoping the weather won't be like this for the rest of the weekend. If it's cooler and it's dry, nothing from today really applies and everyone will be quicker."

Hamilton has won five of the past six races to take his career tally to 80 and he leads the championship by 39 points, with Bottas in second place overall.

Vettel, a four-time F1 champion but runner-up to Hamilton in the past two F1 championships, already trails Hamilton by 100 points and is in fourth overall. He needs a long run of wins to stand any realistic chance of catching Hamilton, but Vettel has not won for the past 18 races.

Another driver with a point to prove heading into Saturday's qualifying and Sunday's race is Red Bull's Pierre Gasly.

The second practice was briefly suspended near the end after Gasly went off the track and smacked into the barriers, mangling both tires on the left side of his Red Bull car.

"We need to get the chassis back and have a proper look. Thankfully it's not the race engine but it is frustrating to lose a car at that point of the session," team principal Christian Horner said. "It's an annoying accident. ... We can't change it now, we have just got to get on with it."

The 23-year-old Gasly is having a difficult first season with Red Bull and has yet to secure a podium finish after 10 races. The Frenchman is sixth in the standings. His teammate Max Verstappen is third and has three podiums, including a brilliant win in Austria.

Earlier Friday, Vettel topped the first practice by .255 seconds ahead of Leclerc. Verstappen was fourth quickest.

Bottas misjudged a late turn, swerved into gravel and only just managed to retain enough control of his car to avoid the barriers.

He lost control of his car at the same turn where Vettel crashed last year and relinquished the championship lead to Hamilton.

Bottas was not at his best on Friday, also going briefly off the track during P2. He is trying to earn a new contract for 2020, amid speculation he could be replaced at Mercedes by French driver Esteban Ocon or Verstappen.

___

More AP auto racing: https://apnews.com/apf-AutoRacing and https://twitter.com/AP_Sports