The win is Ricciardo's fifth Grand Prix victory and first since he took out the Malaysian Grand Prix in October of 2016 but it was also the one he least expected to occur.
Vettel crossed the line in fourth place with Hamilton in fifth.
After his penalty, imposed by the stewards for risky driving, Vettel recovered to finish in fourth, one place ahead of his British rival.
Vettel claimed Hamilton had braked in front of him and he responded by driving into the back of his rival before then bumping the Briton from the side. "I can't quite realize what just happened", said Stroll, barely able to keep the smile off his face. "So I think that in the end I am not.I don't agree with the penalty that I got, because if you penalize me, then you should penalize both of us, because it was not the way to do it". "I don't really need to say any more".
"I have no doubt he brake-checked me", Vettel said.
"I'm sure he didn't do it on objective, but for sure, it was not the right move".
"They've seen today how a four-time champion behaves and I think, hopefully, that doesn't ripple into the younger categories". (It) damaged his rear also I think a little.
"Did I think I would win today?"
"I drove alongside him as I said, and raised my hand to say that's not the way to do it, obviously in that moment, I damaged my front wing and I think he paid a price as well by having slight damage to his vehicle as well".
"So yeah, just went over the kerb, bottomed out, the vehicle jumped and hit him and I got a puncture".
The safety auto came out three times in quick succession before a red flag stopped the race on lap 22 of 51 because debris littered the track.
The Brit was forced to pit by race control to change his headrest which had come loose and was a safety issue. A safety vehicle was deployed on lap 12, for the first time.
Although they have both been racing in F1 since 2007 this is the first year in which they have both had competitive cars.
Vettel came into contact with Hamilton behind the safety auto and got angry about it. Perez was trying to make a move on Vettel when they got started, and Massa was in on it too. "In the middle of the straight you have a chain reaction, he's done it a couple of times, a couple of years ago in China where it was very close to having a crash in the back of the field so if you struggle right behind then you're only going to struggle more in the midfield".
Hamilton, who was leading after making a clean start from the 66th pole position of his career, had initially slowed to avoid the slow-moving safety auto ahead of him, an action that may have caused Vettel to drive into the rear of his Mercedes. Nico Hulkenberg of Renault then followed team-mate Jolyon Palmer into retirement after the German crashed into the wall while Felipe Massa slowed and retired with a broken damper on his Williams.
"The leader dictates the pace", Vettel said. Behind him, team-mate Bottas was back up to eighth and Vettel was closing.
Hamilton led the field into the pit lane as a Mercedes mechanic, armed with a screwdriver and pliers, patched up the bodywork on the rear of his auto.