Verstappen and Ricciardo had carved their way to the top after an inspired gamble by Red Bull team principal Christian Horner to haul both of his drivers in for fresh tyres after Brendon Hartley and Pierre Gasly tangled and the safety vehicle was sent out.
Championship leader Sebastian Vettel, who led from the pole until the first set of tyre stops, dropped back to finish eighth after colliding with Max Verstappen, who was penalised 10 seconds for hitting the German.
It all seemed a very unlikely eventuality after the first few laps which were decidedly soporific by comparison. Max Verstappen (Red Bull) +20,4366.
Hamilton stopped for tires on lap 19, his team ordering him to do the opposite to Raikkonen in the hope of leapfrogging the Finn after his tire stop.
Red Bull could still be in the market to renew the Australian's deal but he remains relaxed about a likely increase in demand for his services.
Bottas stopped on the following lap and emerged into clear air just ahead of Verstappen.
Hamilton escaped without damage to his Mercedes vehicle last week, but the same could not be said for Vettel and his Ferrari here. The Mercedes soon passed Raikkonen, but Vettel followed closely behind. The "honey badger", as he refers to himself, was relentless in his pursuit of race leader Bottas and on lap 46 he dived down the inside of the number 77 Mercedes at a right-hand turn and assumed the lead of the race.
"The safety auto was so unlucky for us", Bottas said over the radio.
Thinking quickly, Red Bull immediately called both their drivers in for new tires.
Ricciardo was the only driver in 2017 to win a race from outside the top five, when he triumphed in Baku past year.
He held second on lap 21 when benefiting from Vettel's slow pitstop, and seized the lead briefly on lap 26 when overtaking Kimi Raikkonen.
"Sometimes you've just got to lick the stamp and send it", he added of the lunge on Hamilton for third place. [The team] said we would double stop. Verstappen also soon overtook Hamilton, who seemed unable to keep pace with the frontrunners.
For Ricciardo, he finally had reason to celebrate after he just missed a podium spot at home in Australia following a grid penalty, and had to retire in Bahrain due to mechanical problems.
Mercedes driver Valtteri Bottas finished second and Ferrari's Kimi Raikkonen third but the driver of the day was without a doubt Ricciardo, whose daring passing moves had the commentators gasping in disbelief.
Lewis Hamilton will move up a place after finishing in fifth with Nico Hulkenburg putting in a great drive to finish in sixth ahead of McLaren's Fernando Alonso in seventh place.
That proved the prelude to an wonderful surge up the order, as Red Bull pitted both Ricciardo and team mate Max Verstappen for fresh tyres.
The Australian has now won six grand prix, and has started fourth on the grid or lower in all of them.
Performing what team boss Christian Horner described as "miraculous" work to get the auto prepared in time to qualify, Ricciardo converted his sixth place on the grid into a win on Sunday.