The situation worked, and by the time the safety vehicle period ended, both drivers found themselves up close with the leaders along with fresh rubber.
The Australian, who started sixth after nearly missing qualifying, made the most of fresher tires to finish 8.8 seconds ahead of Valtteri Bottas in a Mercedes.
All of Ricciardo's wins have come from outside the top three on the starting grid.
The Brit was soundly beaten by Bottas in qualifying, and couldn't match his team-mate or Vettel for pace in the race. No one could have ever predicted that after the way the team has dominated F1 since 2014 and the form they showed in pre-season testing.
Bottas admitted feeling a bit hard done by in his 100th grand prix, particularly since the timing of the safety car's deployment didn't allow him to stop for tyres when the Red Bulls did. From there, he qualified sixth for Sunday's race but there was more drama to come.
"It's so close between Red Bull, Ferrari and us", he said.
Frustrating results for the Scuderia Toro Rosso driver Pierre Gasly who took 18th position and Bredan Hartley who DNF after the teammates had a mild collision. It resulted in Gasly punting the right-rear section of his teammate's auto, which resulted in many bits of sharp carbon-fibre being strewn all over that section of the race track. A safety auto was deployed shortly after that to help clear the debris on the track. And that is where the race turned on its head.
Red Bull's Daniel Ricciardo battles with Nico Hulkenberg.
The safety vehicle was called into action and Red Bull responded, pulling both Max Verstappen and Ricciardo into the pits from third and fifth respectively and fitting them with soft tyres. Had the safety vehicle not been called, or had Bottas pitted at the same time as the Red Bulls, he would have likely have won. On lap 41 the Aussie managed to go past Hamilton to take third.
And two laps later he stormed past Hamilton to move up to third place and set his sights on second placed Vettel while Verstappen re-passed Hamilton (he had earlier passed him at the start of the race) and followed Ricciardo to what could have been a 1-2 finish for Red Bull Racing.
Bottas was second while Raikkonen recovered from his bollard job to finish third ahead of Verstappen and Hamilton.
Verstappen was handed a ten-second post-race time penalty but all eyes were on the charging Ricciardo. Verstappen wound up fifth.
Even with the fresh rubber offering an advantage of more than one second per lap, Ferrari did not react immediately with Vettel at the front, instead waiting until Lap 20 to bring the race leader in.
The rest of the points finishers were Hulkenburg in sixth, Sainz in ninth and the Haas of Magnussen grabbing the last point.
Vettel, who won the first two races of the season for Ferrari, saw his lead over Hamilton slashed from 17 points to nine. He finished fourth instead.