BUDAPEST, Hungary -- Daniel Ricciardo of Red Bull overtook Ferrari's Fernando Alonso near the end of the race to win a thrilling Hungarian Grand Prix on Sunday for his second Formula One victory of the season and his career.
Lewis Hamilton, who started from the pit lane after his engine caught on fire during qualifying, was third, holding off Mercedes teammate Nico Rosberg, who started from pole position.
Ricciardo finished the race 5.225 seconds ahead of Alonso. Hamilton was just 0.632 seconds further back and 0.504 seconds ahead of Rosberg.
Ricciardo, an Australian competing in his fourth Formula One season, made three pit stops -- compared to just two for Alonso and Hamilton -- and his newer set of tires paid off in the end as he surged past the leaders with three laps to go.
"We had the fresher tires but I knew it was going to be an exciting finish," Ricciardo said. "That was a lot of fun, the last few laps.
"I am definitely going to celebrate tonight, party for a few days and enjoy a few days off," he added.
Ricciardo won his first F1 race at the Canadian Grand Prix in Montreal in June and is the only non-Mercedes driver to win this year.
Rosberg still leads the championship with 202 points, followed by Hamilton with 191 and Ricciardo with 131. In the constructors' standings, Mercedes has 393 points, Red Bull 219 and Ferrari has overtaken Williams for third place, 142 points to 135.
Mercedes told Hamilton to let Rosberg pass him as the race was winding down, but Hamilton said he saw no reason to obey team orders considering his good position at the time.
"I was very, very shocked that the team would ask me to do that," Hamilton said. Rosberg "did get close enough to overtake but I was never going to lift off and lose ground to Fernando or Daniel to enable him to have a good race."
"That was a bit strange," Hamilton added.
Hamilton also started from the pit lane at last week's German Grand Prix and moved up to finish third. He had won the last two races in Hungary and was looking for his fifth win on the twisting, relatively slow Hungaroring.
The British driver said his last two performances were "definitely much more satisfying" than even a win achieved from pole position.
He said that starting from the pit lane, without a warm-up lap and with a wet track, made the start of the race even more difficult than the final laps when he managed to hold off Rosberg.
"It was an interesting beginning of the race and I'm very grateful I got through," Hamilton said.
For Rosberg, fourth place on the Hungaroring was his worst result of the season in a race he finished, though it equaled his best effort on this track. Except for dropping out of the British Grand Prix in Silverstone with gearbox problems, he had finished either first or second in every other race.
Rosberg, who has four victories in 2014, one less than Hamilton, admitted to a "massively disappointing" day.
"At the end there was one chance to overtake Lewis in the last lap, but it didn't work out," Rosberg said. "We need to sit down and analyze internally what went wrong today."
Alonso, the only driver to score points at every race so far this season, was pleased to get back on the podium. He was third at the Chinese Grand Prix in Shanghai in April.
"I am happy and proud of the job done," the Spaniard said. "It was probably one of the few podiums we will achieve this season. We can go on vacation now with a good taste in our mouths."
A rain shower just before the start made conditions difficult at the beginning of the race. Several drivers crashed, including Sebastien Grosjean, Nico Hulkenberg and Sergio Perez, and the safety car made two appearances during the race, substantially changing its dynamics.
The championship continues after the summer break on Aug. 24 with the Belgian Grand Prix in Spa-Francorchamps.