Daniel Ricciardo scored his second win of the 2014 Formula 1 season after a thrilling battle in the closing stages of the race.

Nico Rosberg once again put his Mercedes on pole for the race. Sebastian Vettel joined his countryman on the front row in his Red Bull, while Williams rising-star Valtteri Bottas and Ricciardo lined up on row two.

Lewis Hamilton was left dejected after his Mercedes caught fire after a fuel leak, before he had set a time in Q1. He would start from the pit lane. Kimi Raikkonen was dumped out of the first session too, Ferrari keeping the former champion in the garage too long.

Rosberg led the field away at the start in wet conditions. Not having completed a sighting lap, Hamilton spun on his own at Turn 2, but was quickly making his way through the field. Before long he would find himself with the leading group.

The drivers ran to a variety of strategies as the track dried out, but the defining moment for Ricciardo was pitting for fresh rubber during the second safety car period, caused by Sergio Perez spinning into the pit wall.

The positions chopped and changed as the pit stops cycled through. Hamilton, running in front of Rosberg, was ordered to let his teammate past to ease his next stop, but feeling it would compromise his own race, Hamilton held station, saying: “Tell him to get closer.”

With 10 laps to go, the order was Alonso, Hamilton, Ricciardo, Rosberg, the young Aussie having passed the championship leader after his own final stop. At his second attempt, Ricciardo pulled off a stunning move on Hamilton around the outside of Turn 2, before sailing by Alonso at Turn 1 at the start of the next lap.

Rosberg was rapidly closing on third in the last few laps, but Hamilton had just enough in hand to hold onto the position. Felipe Massa was relieved to make the finish in fifth after his recent trials, while Kimi Raikkonen took his best finish of the season so far in sixth.

Sebastian Vettel finished seventh after surviving a carbon copy of Perez’s spin at the final turn. Bottas slipped down the order to eighth, with Jean-Eric Vergne behind. Jenson Button closed out the points-paying positions.

By finishing ahead of Rosberg, Hamilton has closed the gap in the standings to 11 points. He was hoping to be leading the championship at the summer break, but after his disaster in qualifying, the race was always going to be an exercise in damage limitation.

The fight for the championship will only get more intense when the season resumes at Spa-Francorchamps in Belgium on 24 August.

Full Hungarian Grand Prix results after 70 laps

  1. Daniel Ricciardo — Red Bull-Renault — 1h53m05.058s
  2. Fernano Alonso — Ferrari — +5.225s
  3. Lewis Hamilton — Mercedes — +5.857s
  4. Nico Rosberg — Mercedes — +6.361s
  5. Felipe Massa — Williams-Mercedes — +29.841s
  6. Kimi Raikkonen — Ferrari — +31.491s
  7. Sebastian Vettel — Red Bull-Renault — +40.964s
  8. Valtteri Bottas — Williams-Mercedes — +41.344s
  9. Jean-Eric Vergne — Toro Rosso-Renault — +58.527s
  10. Jenson Button — McLaren-Mercedes — +1m07.280s
  11. Adrian Sutil — Sauber-Ferrari — +1m08.169s
  12. Kevin Magnussen — McLaren-Mercedes — +1m18.465s
  13. Pastor Maldonado — Lotus-Renault — +1m24.024s
  14. Daniil Kvyat — Toro Rosso-Renault — +1 lap
  15. Jules Bianchi — Marussia-Ferrari — +1 lap
  16. Max Chilton — Marussia-Ferrari — +1 lap

Retirements: Marcus Ericsson (Caterham-Renault: spin) Romain Grosjean (Lotus: spin) Nico Hulkenberg (Force India-Mercedes: crash) Sergio Perez (Force India: spin) Kamui Kobayashi (Caterham: fuel system) Esteban Gutierrez (Sauber: power unit)