Daniel Ricciardo has produced his best race of the season as Sergio Perez won a chaotic Singapore Grand Prix.
Starting 16th after a horror qualifying session the day before, Ricciardo survived the rain-affected race to finish a season-best fifth.
His teammate Lando Norris finished fourth to help McLaren overtake Alpine into the top four of the constructors' championship.
Six drivers failed to finish the race, while three safety cars and two virtual safety cars were needed for a race that was hampered by a massive downpour less than two hours before the scheduled start time.
With chaos around him Perez was perfect, taking the lead off the start and never relinquishing it.
Ferrari's Charles Leclerc was valiant in second while his teammate Carlos Sainz was a distant third.
The victory was the fourth for the Mexican in his F1 career and one that he rated as his greatest drive.
"It was I think certainly my best performance," he said.
"The last few laps we so intense. I gave everything for the win today."
Perez had fallen off the pace to his championship-leading teammate Max Verstappen in recent times.
The victory released some of the pressure he would have been feeling, jubilantly celebrating with his team over the radio when he crossed the finish line.
"This is how we do it," he said.
"We shut our mouth and we work hard. This is the Mexican way."
Verstappen went into the race with a mathematical chance of winning his second drivers' championship, but a poor start ended any faint hope he had of celebrating a title win at Marina Bay.
Another error on lap 40 when he went off the track cost the defending F1 champion a chance at a podium, as he fought to claim seventh.
Verstappen will have another chance to clinch his second-consecutive championship at the next race in Japan.
McLaren climbs to fourth in constructors' championship
Heading into the race, McLaren was 18 points behind Alpine in the battle for fourth in the constructors' championship.
But Alpine had a nightmare in Singapore, with Fernando Alonso and Esteban Ocon both suffering failures and not finishing the race.
It is the second straight race Alpine has not scored any points, while Ricciardo and teammate Lando Norris both finished in the top five.
Both McLaren drivers drove clean races on a difficult track.
They were assisted when a safety car came out on lap 36 following Alpha Tauri driver Yuki Tsunoda's crash.
The pair had not made their pit stops and were able to save time by coming in for new tyres under the safety car.
Ricciardo was the biggest winner from the safety car climbing from 10th to sixth, before Verstappen then made a mistake and allowed the Australian to climb to fifth.
"I'm very happy. I haven't had a top five all year so I'm very pleased with that," Ricciardo said.
"I feel like some things fell in our favour today, but I also think we were very patient and mature.
"We maximised a top five and it was a big one for the team in the constructors' championship, so everyone's got a smile on their faces."
McLaren goes into the final five races of the season with a four-point lead over Alpine.