Max Verstappen has become the youngest driver to win a Formula 1 race after victory in a dramatic Spanish Grand Prix.
Lewis Hamilton started the race from pole position at the Circuit de Catalunya, but his Mercedes teammate and championship leader Nico Rosberg edged ahead at the first corner.
The Briton tried to take retake the lead a few corners later, but appeared to be edged on to the grass by Rosberg and lost control of his car, hitting the back of the German's Mercedes.
That crash gifted Ricciardo a chance for his first win in almost two years, but his final pit stop saw the Australia slip behind teammate and Red Bull debutant Max Verstappen.
Verstappen, who only began racing in Formula 1 last year with Toro Rosso, held off the challenge of Kimi Raikkonen in the closing laps to take the chequered flag.
Sebastian Vettel withstood a late rally from Ricciardo to take the final place on the podium.
Final standings
1. Max Verstappen (Red Bull)
2. Kimi Raikkonen (Ferrari)
3. Sebastian Vettel (Ferrari)
4. Daniel Ricciardo (Red Bull)
5. Valtteri Bottas (Williams)
6. Carlos Sainz (Toro Rosso)
7. Sergio Perez (Force India)
8. Felipe Massa (Williams)
9. Jenson Button (McLaren)
10. Daniil Kvyat (Toro Rosso)
11. Estaban Gutierrez (Haas)
12. Marcus Ericsson (Sauber)
13. Jolyon Palmer (Renault)
14. Kevin Magnussen (Sauber)
15. Felipe Nasr (Renault)
16. Pascal Wehrlein (Manor)
17. Rio Haryanto (Manor)
Retired
Romain Grosjean (Haas)
Fernando Alonso (McLaren)
Nico Hulkenberg (Force India)
Nico Rosberg (Mercedes)
Lewis Hamilton (Mercedes)