Ricciardo, 25, held off Ferrari's Fernando Alonso to take first place in a race which saw several high-speed crashes after a heavy downpour before the start changed the course of the race.
Rivalry between Lewis Hamilton and his Mercedes teammate and championship leader Nico Rosberg reached a new peak as Hamilton rebuffed team orders to let Rosberg by into third place.
Hamilton declared himself "shocked" at the request.
Mercedes said it would hold a team inquiry. But Hamilton's success trimmed Rosberg's lead in the title race from 14 points to 11. The German now leads with 202, Hamilton has 191 and Ricciardo is third with 131.
Also Read
After overtaking Hamilton, he produced a dazzling pass on Spanish two-time world champion Alonso to take the lead for the third time in a roller-coaster race and stayed there.
"It feels as good as the first win, it really does," the Australian said, referring to his victory in Canada in June. "The Safety Car at first played to our advantage, but the second one didn't really help us!
"But we got there in the end and I had to do the overtaking at the end which was fun. I am definitely going to celebrate tonight, party for a few days and enjoy a few days off.
Alonso, who will be 33 on Tuesday, said: "I am extremely satisfied, it has been a tough season so to get a podium is always a nice surprise. We took a gamble to try to get the victory and we got very close."
It was Alonso's second podium this year and, remarkably, achieved on soft tyres that he nursed through the final 31 laps. But it left Ferrari now without a win in 25 races since he triumphed in the 2013 Spanish Grand Prix.