Max Verstappen fought back from an early spin to win the Spanish Grand Prix after title rival Charles Leclerc retired from a dominant lead.
It was Verstappen's fourth victory in six races this year, helped by Red Bull imposing team orders on Sergio Perez.
It gives him the championship lead for the first time in 2022 and he heads to Monaco next weekend with a six-point advantage over Leclerc.
Mercedes' George Russell took a strong third after a long and valiant attempt to hold Verstappen at bay early in the race.
And his team-mate Lewis Hamilton fought back to fifth place following a first-lap collision with Kevin Magnussen's Haas, which gave the seven-time champion a puncture and dropped him to the back of the field.
Hamilton moved into fourth behind Russell with a move on Ferrari's Carlos Sainz around the outside of Turn One with six laps to go.
But Hamilton lost the position again after being told to slow down because he had a coolant leak, and could not use full throttle.
Russell received the same message to lift-and-coast at the end of the race. In his case, his car was overheating throughout the grand prix.
- Advantage Verstappen but positives remain for Leclerc
- Recovery in Spain 'better than a win' - Hamilton
- Verstappen wins Spanish Grand Prix - as it happened
Verstappen salvages victory from mistake
Verstappen has had his share of bad luck this season, with two retirements from the first three races, but he certainly enjoyed some good fortune in Spain.
Leclerc was on course for a comfortable victory after a rare error from Verstappen saw the world champion spin into the gravel at Turn Four on lap nine.
The race had looked finely poised between the two until that point, with Leclerc leading by two seconds, but Verstappen's spin changed the complexion of the race.
It put him behind Russell, and despite the Red Bull's much greater pace, Verstappen was unable to pass the Mercedes.
Verstappen was held back by a DRS overtaking aid that rarely worked, but at the same time Russell put in a superb defensive drive to hold the Red Bull back for 19 laps.
In the end, Red Bull decided to switch strategy to get Verstappen past Russell, and stopped him on lap 28 for a set of soft tyres.
That allowed him to run in clear air, and when he stopped again on lap 44 for a final set of mediums, he emerged ahead of Russell, with only Perez ahead.
Red Bull told the Mexican not to hold Verstappen up, and he was past into the lead a few laps later, a decision Perez said was "unfair". On his slowing down lap, he said: "I am happy for the team, but we have to speak later."
Heartbreak and concern for Leclerc and Ferrari
Verstappen's spin left Leclerc alone and unchallenged out front and he was nearly 30 seconds in the lead when he made what should have been his first pit stop for fresh tyres on lap 21.
The Ferrari re-emerged nearly six seconds in the lead, and with Russell still holding back Verstappen, Leclerc was 12.6secs in the lead and in total control when his engine failed six laps later.
Leclerc will be a strong favourite for victory in Monaco given the Ferrari's pace in the slow- and medium-speed corners in Spain, but the team are facing a difficult moment and must bounce back quickly.
Leclerc's team-mate Sainz was unable to salvage their day.
He made the same mistake as Verstappen, albeit two laps earlier - both drivers caught out by a tail wind at Turn Four. And after that, hampered by floor damage that reduced his car's downforce, he lacked the pace to recover as strongly as might have been expected.
He would have finished a disappointing fifth had it not been for Mercedes' reliability problems at the end gifting him a free pass back on Hamilton.
A mini Mercedes revival
Mercedes arrived in Spain with a car upgrade which succeeded in limiting the porpoising problems on the straight that have hamstrung them so far this season.
Russell followed it with the team's best grid position of the year in fourth place, and he drove an outstanding grand prix.
Holding off Verstappen, Russell displayed the sort of defensive skills that his forerunner in the seat, Valtteri Bottas, so often failed to do.
Ultimately, Red Bull were able to pincer Mercedes on strategy and unleash the extra pace of their car and Russell was helpless to hold them back.
Hamilton, meanwhile, had a dispiriting start. He was fighting for fifth with Sainz going into Turn Four on the first lap, but he collided with Magnussen as the Dane tried to go around the outside and punctured his left-front tyre.
Rejoining at the back, Hamilton soon radioed to the team that he thought they might be better to retire and save engine miles. They replied that they thought he could recover to eighth.
He over-achieved significantly, driving a superb comeback race to enter the final laps behind Russell, only to slip back again.
Team boss Toto Wolff came on the radio to Hamilton on his slowing-down lap to tell him that he had the fastest race time of any driver.
Hamilton was 54 seconds off the lead after his early pit stop and only 40 seconds back heading into the final three laps, before being told to save the car, although the picture is clouded by the fact that Leclerc retired and Verstappen was both held up by Russell and cruising after he claimed the lead.
Behind him, Alfa Romeo's Bottas took sixth, from the Alpine of Esteban Ocon and McLaren's Lando Norris, who had been feeling ill all weekend and had to see a doctor after the race.
Norris, who was excused post-race media duties, later revealed in a team statement he had been suffering from tonsillitis.
"Today was tough," said Norris. "I was feeling really unwell before the race as I'm suffering with tonsillitis, and that, in combination with the high temperatures, made this one of the hardest races I've ever done.
"I've been a bit on the back foot this weekend as most of my energy has been spent fighting off this illness. I've had to miss a lot of engineering sessions, which has compromised my weekend, and I definitely wasn't as prepared for the grand prix as I could have been."
And local hero Fernando Alonso drove superbly to recover to ninth after the two-time champion started from the back because of an engine change before the race.
Yuki Tsunoda took the final point for Alpha Tauri.
- The Rise of the Premier League: The story of how England's new top flight was formed, told by its stars
- Navalny: Unravelling the plot against Putin's opposition