Red Bull’s Ricciardo took full advantage after race leader Lewis Hamilton was forced to pit because of a faulty headrest and Vettel received a 10-second penalty for driving into his Mercedes rival while behind the safety car.
Hamilton, who had controlled the race from pole, was first bumped from behind by Ferrari’s Vettel, who then pulled up alongside him and appeared to turn in deliberately.
Vettel claimed that Hamilton had been deliberately “brake-checking” him, but the stewards saw it differently and handed him the stop-go penalty.
After Vettel served his penalty, he came out of the pits ahead of Hamilton and maintained his position as the pair finished fourth and fifth, leaving the German 14 points clear after eight rounds of the 2017 championship.
Hamilton was left to complain over race radio at what he saw as too lenient a penalty for Vettel. “Not enough for driving like that, you know that,” he told race director Charlie Whiting.
And the war of words continued after the race as a furious Hamilton vented his anger and frustration over Vettel’s actions.
“If he wants to prove himself he is a man he should do it out of the car, face-to-face,” he told BBC Radio Five.
“Imagine all young kids watching F1 today and seeing that sort of behaviour from a four-time world champion.”
Behind Ricciardo, who started 10th on the grid, Canadian teenager Lance Stroll looked set to finish second until pipped on the line by Hamilton’s Mercedes teammate Valtteri Bottas.
The Williams new boy is the youngest driver at 18 years of age to claim an F1 podium in his rookie season. “I am just lost for words,” said Stroll at the post-race presentations. “We just stayed out of trouble.”
It was also a remarkable drive by Finland’s Bottas, who collided with Ferrari’s Kimi Raikkonen on the second corner and dropped back to 20th before working his way back through the field in the 51-lap race.
Both Ricciardo and Bottas were assisted by no less than three safety cars and eventually a red flag as race officials cleared debris from the street circuit in Baku.
“It was a crazy race,” said Australia’s Ricciardo, while admitting that thoughts of victory had been far from his mind until the incidents involving Hamilton and Vettel.
It is his fifth career victory in F1.
Esteban Ocon took sixth for Force India despite crashing into his teammate Sergio Perez while fighting for third spot, while Fernando Alonso scored the first points of a disastrous season for McLaren in ninth spot after a spirited drive.