Formula 1 fans have enjoyed some great racing in 2017, and having Ferrari fully up to speed and pushing Mercedes ensures that each weekend has an unpredictable outcome.

Spain was as good as it gets: fans witnessed a fabulous on-track fight between two of the all-time greats, and between two clever teams who are pushing the limits on strategy and R&D. It was fabulous stuff, and at a track that has seen its far share of turgid processions down the decades.

Over the years fans rarely had the chance to see Lewis Hamilton and Sebastian Vettel go wheel-to-wheel for a race victory, but they did so in Barcelona, and in some style.

They came close to touching at two critical moments, on the first lap and again when Vettel emerged from his final stop just in front of his rival – and at those points no quarter was given by either man.

It was great stuff. Then later Hamilton secured his second win of the season with a proper on-track pass, rather than through some chess moves around the pitstops.

Of course he was assisted by DRS, but an overtake it was, nevertheless.

Action-packed first corner

Heading into the race, tyre usage was a major talking point, especially as there was a significant delta between the soft and medium. It was pretty clear that teams would run two stops, and try to minimise their time on the medium. How that might pan out was the big question.

The other key to the race was the start, and once again in 2017 we had some action as Vettel forced his way past Hamilton. In third place Valtteri Bottas backed out of it to avoid any risk of getting involved with his teammate.

That led to a three-into-two situation with Kimi Raikkonen and Max Verstappen alongside him, and the subsequent contact put both the Ferrari and Red Bull out of the race.

That was a great shame, for having Raikkonen in the mix at the front would have added to the fun. And after losing out at the start Bottas fell back almost immediately, and the Russian GP winner was never in the fight for victory – although he still had a role to play.

He was at a loss to explain his struggle for pace in the first stint, insisting it was nothing to do with locking up in Q2 on the set of tyres he had to start the race with.

The one clear handicap he did have was an engine that was on its fifth race weekend, and had been tested by the hot conditions in Russia. Power units always lose their edge with age, and Hamilton had the benefit of the latest spec.

With both Finns out of the picture, it was now a straight fight between Vettel and Hamilton. Vettel put in a typically awesome first lap, opening up 2.2s on Hamilton and benefiting from the fact that the Mercedes driver had lost some momentum when edged off the track at the start.

After three laps Vettel was 2.7s ahead, and it began to look as if he would make his escape – but then Hamilton held the gap at around the 2.5s-2.6s mark for a while.

Told that it was a "critical time of the race" and that he had "give everything you've got," Hamilton went into "leave me to it" mode, letting the team know that he was already doing just that.

The question now was who would blink first and pit?

Hamilton waits it out

Just 14 laps into the race it was Vettel who came down the pitlane first, taking on another set of softs. He came out behind Daniel Ricciardo, as Mercedes knew he would.

There was no point in Mercedes responding on the next lap, because Hamilton would have just come out behind Vettel. In fact, the Ferrari only lost a little bit of time behind Ricciardo before making his way past the Red Bull.

The logical thing was to do something different, so he stayed out for another seven laps. Normally people do that sort of thing mainly to ensure they have younger tyres than their main rivals later in the race, but this time there was an added twist – Hamilton took on a set of the medium tyres, rather than softs.

Logic suggested that Vettel's advantage would quickly increase, but that didn't happen. Not only did the mediums turn out to be more effective than we might have anticipated, but Mercedes had a joker up its sleeve in the form of Bottas.

Having got by Ricciardo relatively easily, Vettel enjoyed a clear track for a while, at least until he came up behind the number 77 Mercedes. With third in effect in the bag – Ricciardo was no threat – the Finn was now employed as part of a clever team strategy, his job being to slow Vettel's progress, something he was perfectly entitled to do.

Indeed, Ferrari admitted in Australia that they would have done much the same thing, using Raikkonen to slow Hamilton. However, the way the race played out they didn't have to, because Verstappen did the job instead.

"I was catching him but I knew they wouldn't pit him," said Vettel of Bottas. "He was all over the place with his tyres, so they used him a bit to block me."

Vettel caught Bottas just as Hamilton pitted, and over the three laps he stayed behind his advantage over Hamilton went from 7.8s to 5.8s to 3.7s, before he finally got past in a bold move.

Hamilton, meanwhile, was finding some good speed on his new mediums, and against Vettel's seven-lap older softs, it was a closer contest than had been anticipated.

Inevitably Vettel did open the gap up, but only to the 6.5-7.5s range. And of course he still had to change to the slower tyre at some stage. Hamilton, meanwhile, had to be reassured that things would go his way when that happened.

VSC changes the game again

The race took another twist when Stoffel Vandoorne's demise led to a Virtual Safety Car. Several cars down the field took advantage of it to make stops that would prove less costly than those under green, but at the front, it was a bit more complicated.

The top guys all stayed out, but then just as the VSC was withdrawn at the end of lap 36, Hamilton came in.

Vettel, having already passed the pits, had to wait.

He came in on the next lap, under green, and as he emerged he was shocked to find that what had been an advantage of almost 8secs had evaporated, thanks to Hamilton's VSC stop.

He just managed to keep ahead as they barrelled into Turn 1, an angry Hamilton suggesting that the move was "dangerous."

It was then game on. Vettel had the lead, and was on the medium tyres, which were always going to be slower. But Hamilton's softs had to last a marathon 30 laps, and that would be a challenge, especially given the pace he was running at.

Fans were set for great finale, with traffic also playing a role, as both men had to make their way past a lot of drivers who were in the middle of their own battles. Hamilton had the momentum, and at the start of lap 44 he used DRS to sweep past Vettel to take the lead.

"No chance, like a train, like a train," Vettel told his pit. "Don't give up, he will struggle with his tyres," was the reassuring reply.

Indeed, within a couple of laps Hamilton reported that he already had overheating rears, and he still had some 20 laps to run. When the message was passed on Vettel wryly noted, "they could have done that a couple of laps ago, when he was still behind..."

A lot of conversation was heard between Hamilton and his pit about what he should do – take it easy and save the tyres for the end, or push and open a gap to give himself a margin when the tyres did start to drop off.

He was told to pursue the latter option.

Threat of Plan C

Vettel stayed within a couple of seconds of Hamilton, but finding the pace to pass with the mediums was always going to be be difficult. Around the lap 50 mark Ferrari talked about Plan C – which was for him to pit again, drop back, take on some fresh softs and then have the pace with which to sprint.

Vettel agreed that he had "nothing to lose" by doing that – he would finish second anyway – and Hamilton was duly informed that he might have to get a move on to protect himself from such a charge.

It was stick or twist for Vettel… and he stuck.

There was to be no late pitstop and dramatic charge on new rubber, and instead he sat it out and waited in hope for Hamilton's mediums to lose their edge. Mercedes knew that the danger had passed, telling Hamilton "that's now off the table" when he asked if Vettel would stop again.

In the end, Hamilton kept his tyres alive. Knowing that he was going to make it home safely in front, he celebrated by setting the fastest lap with two laps still to run – showing just how well he had protected them.

It must have been crushing for Ferrari to see that pop up on the timing screens.

He duly crossed the line safely in front after what had been a superb race. A quarter of the season has gone already, but there are still 15 more races to enjoy. It promises to be fun.

"I'm very happy when we have the chance to race Mercedes," said Vettel. "They have been proving over and over in the last few years that they are the team to beat.

"We are giving them, so far, a good run for their money. I think we can be very happy – but today we're not entirely happy because the win was there, the car was quick enough but the way the race happened, it wasn't meant to be."