SAKHIR, Bahrain — Lewis Hamilton's surprise win for Mercedes at the Bahrain Grand Prix on Sunday was the latest present from rival Ferrari, served on a silver plate and wrapped with a red ribbon.

Hamilton won at a canter despite the Silver Arrows lagging behind the red Ferraris for most of the race.

First, Sebastian Vettel imploded under pressure from Hamilton, spiraling out of contention some 20 laps from the end as the pair of five-time Formula One champions fought for what seemed like second place.

Then it got even worse for Ferrari as race leader Charles Leclerc's engine started losing power.

"(It was) just a loss of power, completely," Leclerc said. "There were no signs before."

It was the F1 equivalent of an open-goal in soccer for Hamilton, who took full advantage before getting a post-race hug from former Manchester United and England star David Beckham, who waved the checkered flag on Hamilton's 74th career win. Only seven-time F1 champion Michael Schumacher has more with 91.

Leclerc finished third behind Valtteri Bottas as Mercedes somehow clinched a second straight 1-2 from two races, having been slower than Ferrari in pre-season testing and in Bahrain. Ferrari looked in ominous form after dominating every practice session and every section of qualifying on the 5.4-kilometre (3.3-mile) desert circuit.

"We were lucky. Ferrari out-performed us from the get-go," Hamilton said. "It definitely feels weird. But what can you do? You can't deny yourself (victory)."

Then, to rub further salt into Vettel's wounds, Hamilton heaped praise on Leclerc — who drove brilliantly to secure pole position on Saturday and was only denied victory by problems with his car.

"Charles was incredible this weekend. He was so much faster than his teammate," Hamilton said. "He has a bright future ahead of him."

A despondent Leclerc thought he was going to become the third-youngest winner of an F1 race — after Max Verstappen and Vettel — having already become the second youngest to qualify on pole after Vettel.

"You have a dream since childhood, your first win in Formula One," the 21-year-old driver from Monaco said.

Red Bull's Verstappen placed fourth with Vettel crossing in fifth.

Leclerc only finished third because the safety car came out near the end after the Renaults of Daniel Ricciardo and Nico Hulkenberg went off track.

Under safety car rules drivers must hold position. Verstappen could not attack and missed out on a second straight podium, after third place at the season-opening Australian GP two weeks ago behind Hamilton and Bottas.

Leclerc picked up a bonus point for posting the fastest lap. But Ferrari will know third and fifth spots were simply not good enough, after fourth and fifth in Australia.

"We'll check everything we can," Ferrari team principal Mattia Binotto said.

Ferrari last won the drivers' title in 2007 with Kimi Raikkonen, and its constructors' title the following year remains its last. In the past two seasons, Ferrari challenged strongly before badly fading in the second part of the season after a series of mishaps, strategy errors and mistakes by Vettel.

Ferrari replaced struggling team principal Maurizio Arrivabene with Binotto, formerly Ferrari chief technical officer. But he's in much the same position: with a fast car and a driver — Vettel — appearing prone to problems and errors. Heading into the Chinese GP in two weeks' time, Ferrari has to find a way to stop throwing away points and Vettel needs to regain control.

Vettel did well to overtake Leclerc at the start of Sunday's race, but Leclerc reclaimed his lead soon after with an audacious move on the German driver's outside.

Montreal's Lance Stroll finished 14th.

It looked even more like being Ferrari's day when Hamilton went too wide on Lap 20 and drifted further behind Leclerc. Vettel overtook him on Lap 23 to put Ferrari 1-2.

As it turned out, Hamilton needn't have worried much because another Ferrari flop was on the way.

It happened on Lap 39 of 57.

Vettel initially fended off Hamilton's attack well, but then lost control and span his car, prompting hands on heads in the Ferrari garage.

Question marks were raised in 2017 and 2018 about Vettel's repeated mistakes under pressure , particularly when he crashed while leading the German GP last year.

Leclerc made no mistakes, but instead was undone by his car.

Panic crept into his voice with about 10 laps left.

"Something strange with the engine," Leclerc said, his lead rapidly dwindling. "What's happening?"

He soon knew.

Hamilton surged past him for his first Bahrain win since 2015 and third overall.

Bottas leads the title race, ahead of Hamilton 44-43, because of his fastest lap in Melbourne.

___

More AP F1 coverage: https://apnews.com/FormulaOne and https://twitter.com/AP_Sports