For much of the race it looked like Sebastian Vettel would become the first driver to win two races this season, but then on lap 35 Valencia turned into a less predictable circuit.
When the Red Bull of Vettel suffered from an alternator issue, Fernando Alonso moved up into first and held on to win in front of his home crowd.
Alonso became the first driver to win two races this season and his victory at the European Grand Prix on Sunday moved him to the head of the drivers standings, twenty points ahead of Red Bull's Mark Webber.
His win came despite the fact he started outside the top ten grid positions and had to wrestle through the pack. He moved up to eighth on the first lap and was into seventh by the 12th. Three retirements in front of him did the Spaniard little harm as teams with a Renault engine suffered on the street circuit.
"I can't express in words my feeling at the moment, to win my home grand prix is a unique feeling, and with the football I'm feeling proud to be Spanish right now," Alonso said.
Kimi Raikkonen finished in second and Lewis Hamilton dropped out of contention when he collided with Pastor Maldonado on the second last lap to move Michael Schumacher into third.
Although the crowd in Valencia went wild for their compatriot, they were more than welcoming to Schumacher who returned to the podium for the first time since returning to the sport in 2010.
The German drove a superb race passing several cars in the final stages and showed signs of the skill that made him a seven-time world champion.
When Hamilton crashed out late, Schumacher was hoisted into the top three to make him the oldest podium finisher since Australian Jack Brabham, in 1970, when he was 44.
"I didn't think about a podium, not even at the end of the race,'' said Schumacher.
"At the end I asked the guys where we finished and the boys told me that's third. I can't believe that, I didn't expect it."
After struggling in qualifying, Alonso clinched an unlikely victory by passing a number of drivers on Valencia's 5.4-kilometer (3.3-mile) street circuit notoriously tough for overtaking.
It was by far the most exciting race the Valencia street circuit has ever produced and it was won by a top-drawer performance from Alonso.
Albeit helped by a rare retirement from Vettel.