Sergio Perez won a bizarre Azerbaijan Grand Prix on a day neither championship contenders picked up points.
Max Verstappen looked set to extend his championship lead but a tyre failure with five laps to go saw his race come to a premature end - the second Pirelli tyre failure of the afternoon after Lance Stroll suffered a similar fate earlier on the race.
Perez started sixth and managed to pass Carlos Sainz and Pierre Gasly at the start before getting by Charles Leclerc as the Ferrari suffered with race pace.
Both Red Bulls jumped leader Lewis Hamilton when the Mercedes man was held in his pit box to avoid Gasly coming in for his stop, and it looked like a routine run to the finish for the Milton Keynes team.
But after Verstappen's retirement and red flag, the teams were able to change tyres for a mad-cap two-lap shootout.
And despite getting off the line brilliantly, Hamilton out-braked himself and missed the first corner, dropping him out of the points.
It meant Perez claimed his second career victory in only his sixth race for his new team, ahead of a brilliant Sebastian Vettel in the Aston Martin.
Perez said: "I'm so happy. Normally baku is pretty crazy. Max deserved the win and it would have been wonderful to the team to get a 1-2. We nearly had to retire the car but we managed to get to the end.
"We had strong pace all the way through, but Lewis pushed all the way. At the start, I got a poor one, braked as hard as I could but it didn't work for him.
"This is a strong boost of confidence for me in this car."
Gasly held off a spirited fight from Leclerc and Norris on the final lap to claim the last podium.
Fernando Alonso was sixth, ahead of Yuki Tsunoda, Carlos Sainz, Daniel Ricciardo and Kimi Raikkonen.