Hamilton's Mercedes teammate Valtteri Bottas snatched second place from 18-year-old Williams driver Lance Stroll in the final straight, as Vettel finished fourth ahead of Hamilton to extend his championship lead to 14 points.
Despite Ricciardo's win, the race will be remembered for the angry confrontation between former world champions Vettel and Hamilton.
Ferrari star Vettel was handed a 10-seconds stop-go penalty during the race for "dangerous driving" after he deliberately drove into Hamilton's Mercedes while both were following the safety car.
"I think it's just not driver conduct. It's dangerous driving and to get a 10-second penalty for that... I don't need to say anything else," Hamilton told Sky Sports.
More From This Section
Vettel pleaded innocent.
"Nothing happened, did it? He brake checked me as well, so what do you expect?," the German told Sky.
"I'm sure he didn't do it on purpose but for sure it was not the right move. If I'm struggling, people at the back struggling even more, so I don't think it was necessary.
"I passed him because he pitted. After the incident, we were side by side, I raised my hand and told him, well I didn't say anything, but showed him that I wasn't happy with that."
Making the most of a series of extraordinary incidents and interventions in an action-packed race, which included three safety car interventions and a red-flagged stoppage, Ricciardo, who started 10th, roared home 3.904 seconds ahead of the rest to deliver his first win of the season.
Hamilton, who had dominated after a strong start from his 66th pole position, was also undone by a loose headrest that caused him to be ordered to pit for repairs, for safety reasons.
Bottas meanwhile produced a brilliant drive to take his fifth podium finish of the season, having dropped to the back of the field after a first-lap bump with fellow Finn Kimi Raikkonen.