Red Bull's Sebastian Vettel held off a stern challenge from McLaren's Lewis Hamilton to win a thrilling Spanish Grand Prix.
It was Vettel's fourth win in five races, but the huge pace advantage Red Bull showed in qualifying vanished and Hamilton pressured him throughout.
Hamilton's team-mate Jenson Button made one fewer stop in taking third.
Ferrari's Fernando Alonso led the first 18 laps but faded to fifth behind Red Bull's Mark Webber.
"That was an immense fight," said BBC F1 co-commentator David Coulthard and Vettel's pleasure at holding off Hamilton's challenge was clear from the world champion's thrilled response to his team's congratulations on the slowing down lap. "Yabba-dabba-dee," the 23-year-old screamed.
The world champion acknowledged he had been pushed hard until the end.
"McLaren were very strong, Lewis in particular," he said.
"The last few laps I felt like China, with my tyres falling away. He [Hamilton] was always getting in the DRS zone but in the last few laps I got a good run in the last sector to make it stick."
While frustrated at finishing just 0.6 seconds behind Vettel, Hamilton was hugely encouraged by McLaren's pace compared to the Red Bulls.
"I wasn't expecting to be so quick today, as the race went on we had some serious pace, but he [Vettel] was massively quick in the high speed corners," said Hamilton.
BBC F1 commentator Martin Brundle added: "That will be a warning sign to Red Bull."
Red Bull had been expected to dominate the race after qualifying nearly a second clear of their rivals, with Webber on pole ahead of Vettel.
The thrills began as soon as the lights went out at the start of the race, when Alonso catapulted away from fourth place on the grid to lead into the first corner.
Alonso's start was one of the best seen for a long time as he shrugged off the disadvantage of starting on the dirty, more slippery side of the grid to power off the line.
He tracked the Red Bulls down to the first corner and dived down the inside to claim the lead, drawing huge cheers from the 80,000 crowd of his adoring compatriots.
"That was fantastic," said BBC F1 co-commentator David Coulthard. "The motivation he had to lead this grand prix."
Ultimately, it did not help Alonso but, while holding off a train comprising Vettel, Webber and Hamilton, he was able to lead superbly through the first pit stops until the key turning point came on lap 18 of the 66-lap race.
That was when Vettel came in for his second stop, and he made up enough time on his out lap to jump Alonso, who pitted on the next lap in a vain attempt to hold on to the lead.
Hamilton and McLaren did not make that mistake, and were able to keep the pressure on the Red Bull.
They kept running until lap 23, coming out just over four seconds behind Vettel.
They battled intensely for the rest of the race, Hamilton edging ever closer to Vettel before both their third and final pit stops, closing to within 1.2 seconds each time, only to lose a second at the stops on both occasions.
They spent the final 10 laps nose to tail and although Vettel's pace was compromised at times throughout the race by his Kers power-boost system working only intermittently, it returned for the final laps of the race.
Hamilton had a look at passing him a couple of times but Vettel was able to hold on.
Button finished more than 30 seconds behind the lead pair after choosing a three-stop strategy compared to the four of the other leading runners.
"We never planned to do anything but a three-stop strategy as I thought doing two stints on a prime tyres was no good," said Button.
"It would have been interesting to see what would happened if I didn't have a bad first lap, but all in all it was a good day and good to get a podium."
The decision helped him push Webber down to fourth place and the Australian will rue a poor start from pole position that left him third by the first corner, from which point his race unravelled.
Webber spent much of the race stuck behind Alonso, finally clearing the Ferrari when it pitted on lap 39.
Webber has been one of the harshest critics of some of the easy passes that have come about as a result of the rapidly degrading tyres and DRS overtaking device that have been introduced this season.
But he may well have been wishing for some of the easy passes that were seen at the previous race in Turkey. They vanished at this track where overtaking has always been so difficult.
Alonso fell further back throughout the race, but was well clear of the Mercedes of Michael Schumacher and Nico Rosberg, which were sixth and seventh.
And Alonso admitted that his result was "what we deserved this weekend".
"It looks a little bit sad when you start losing positions but we need to understand that P1 was maybe not our position at that moment," the Spaniard told the BBC.
"We were not competitive, especially in the race pace, we were too slow - with the hard tyre even more.
"There are clearly two teams ahead of everybody. We need to change this situation. We need to work more and more and we'll see. Monaco is so special, anything can happen but in Canada, we need to make a step forward."
Renault's Nick Heidfeld was eighth, with the Sauber drivers Sergio Perez and Kamui Kobayashi took the final two points positions.
Red Bull team principal Christian Horner was a relieved man.
"It was a full-on race, Fernando changed the dynamics completely getting into the lead," said Horner.
"He did not have fantastic pace but it was very hard to overtake. We managed to get Seb past with the undercut and he made that really work for him and hang on, but McLaren gave us a tough run today."
Hamilton, Button, Webber and Jaime Alguersuari were investigated after the race for not slowing down when yellow flags were waved after Heikki Kovalainen crashed out in his Lotus.
All four were subsequently reprimanded but no further punishment applied.