Red Bull's Max Verstappen dominated a wet-dry Emilia Romagna Grand Prix to revive his title hopes as rival Charles Leclerc threw away third place with a costly error.
The driver was trying to pass Verstappen after a late pit stop when he lost control at the Variante Alta chicane.
Leclerc had to pit for a new front wing and fresh tyres and dropped to ninth and could only recover to sixth.
Verstappen was able to cut his deficit to Leclerc from 45 points to 27 thanks to the error.
The driver of the car appeared to be heading for a third place until Leclerc made a mistake. He threw away a large part of the advantage he had gained because of Red Bull's poor early-season reliability.
The fact the error happened in front of a packed crowd of their passionate Italian tifosi will make it feel worse, especially as Leclerc had emphasized before the weekend the need to not over-hype things.
It made for a nightmare race for Ferrari, who had lost their team-mate Carlos Sainz on the first lap when he was tipped into the gravel by Daniel Ricciardo.
The error cost Leclerc seven points.
Lando Norris of McLaren took third place after an impressive drive, ahead of George Russell of Mercedes and Valtteri Bottas of Alfa.
Lewis Hamilton was stuck behind slower cars and couldn't pass, finishing in 14th place.
Despite the difficult conditions, the most boring race of the season so far was enlivened by the late drama.
After converting his pole position into a lead at the first corner, Verstappen was in total control.
The rain before the start forced everyone on to wet-weather tyres and an apparent off-set in grip between the pole position side of the grid dropped Leclerc from second on the grid behind Perez and Norris by the time they reached the first corner.
After a restart from an early safety car period, Leclerc passed Norris on lap eight.
As the track dried and the time came to change to dry tires, the driver of the Ferrari tried to hold off the Red Bull driver.
Perez was the first driver to pit for dry tires on lap 18 and a fast in-lap by Leclerc ensured that he emerged from his stop a lap ahead of the Red Bull.
Perez was able to pass into the second chicane and once in front, he was able to hold Leclerc at bay until the driver of the other car made a mistake.
Perez showed strong pace, but a couple of small mistakes dropped him to 10 seconds behind Verstappen, who sailed serenely on to his second win of the year.
After a lonely race behind the big two, Norris was able to hold off Russell when the field switched to dry tires.
Russell jumped from 11th on the grid to sixth on the first lap.
He fought past Kevin Magnussen's Haas and benefited from Leclerc's error but was unable to close on Norris, not helped by Mercedes being unable to adjust his front wing as planned during their pit stop, which meant he was battling with a difficult balance for the rest of the
The man who replaced him at the world champion team was not able to get close enough.
After his mistake, Leclerc was able to pass Magnussen, but he looked distraught after climbing out of the car.
Hamilton's race fell into a dispiriting pattern after he was unable to make up ground at the start.
The lack of straight-line speed of the Mercedes meant he could not pass Lance Stroll, who was in 12th place.
He was impeded by Alpine's Ocon at the pit stops, and the five-second penalty earned by the Alpine was no solace as Hamilton was unable to pass in what was one of his cars.
The performance of Verstappen in the most convincing race of the season so far will cause some concern at rivals.
The new race in Miami is a glamorous event in which F1 has invested a lot of effort and hope.