Picture: Albert Gea / Reuters.

Barcelona – Mercedes celebrated a memorable victory for Lewis Hamilton over Ferrari rival Sebastian Vettel at the Spanish Grand Prix in which everything seemed to come together for the team in a race they had no right to win.

Vettel had begun brilliantly in getting past Hamilton on pole and soon left the British driver gasping – literally and figuratively – as his team pondered how best to recover against the impressive pace of the Ferrari.

In the end it was, in the words of Mercedes motorsport chief Toto Wolff, a mixture of "brilliant teamwork of strategy and Lewis' driving" – plus a helping hand from team-mate Valtteri Bottas – which enabled the three-time Formula One champion to take the chequered flag ahead of Vettel.

Most Formula One observers agreed that they had seen one of the best races ever at the Circuit de Catalyuna, and probably the most gripping of the season.

Formula One is hoping it is a foretaste of things to come in what could a be a titanic duel between two drivers with seven world championships between them.

The battle in Barcelona is "a mighty appetiser for the rest of the season," Britain's Guardian wrote.

It was a tough race for Hamilton, who saw Vettel speed away from the start and had to fight hard to stay within distance. The Briton sounded breathless over team radio as he questioned the team over pit stops and tyre choices. Afterwards he said he "probably lost two kilos."

In the end some quick thinking by the team's strategists got him into a position where he was able to hurtle past Vettel on lap 44 – fittingly for Hamilton's car number 44 – of the 66 laps.

The key to victory was the decision by Mercedes to switch their tactics as a result of a virtual safety car period. Ripping up their previous plans, they brought Hamilton in for a tyre change right at the end before Ferrari could respond.

Vettel came in a lap later and was then surprised to emerge from the pit lane right alongside Hamilton, a previous eight-second advantage vanished. The two fought wheel to wheel with Vettel getting the better of the exchange, before Hamilton was later able to overtake.

Vettel was still baffled after the race as to how he had lost his relatively comfortable lead. But as Wolff explained, the time lost making a pit stop under the virtual safety car period is less than under full racing conditions

"The magic call was the one to take the pit stop at a time when it looked like the VSC (virtual safety car) would end soon," he said. "We timed it perfectly, I really take my hat off to James [Vowles, chief strategist] and his group of strategists."

Hamilton was also helped by team-mate Bottas, who was in the lead on an extended stint and managed to hold up Vettel up for a handful of laps following the Ferrari driver's first pit stop.

Vettel brilliantly got past the Finn after a double feint but said: "We lost a lot of time fighting Valtteri. We lost four seconds. I was catching him but I knew they wouldn't pit him."

Bottas, on an old engine after a power unit switch before qualifying, eventually retired, joining Ferrari's Kimi Raikkonen and Red Bull's Max Verstappen, who collided on the first turn, among the drivers who failed to finish.

Despite being beaten by Hamilton, Vettel collected his fifth top-two finish in as many races to stay six points ahead of Hamilton in the standings, with the Monaco Grand Prix next up on May 28.

There was mutual respect after the race, the German praising Hamilton and not faulting his own team's race strategy. "Well done to him, he won it fair and square," Vettel said.

Both teams go to Monaco with confidence high.

"People have been asking me if Lewis is now back. The truth is he has never been away – and today's showed it," Wolff said.

Ferrari team principal Maurizio Arrivabene said: "Shame for the end result, but we leave Spain knowing that we can count on a car that is solid and very quick."