Daniel Ricciardo has won a thrilling Malaysian Grand Prix at Sepang as Red Bull took full advantage of a dramatic retirement from the lead for Lewis Hamilton and a turn one tangle for Nico Rosberg that forced him to fight back from last to third.

Hamilton had looked on course for a comfortable seventh win of the season that would have taken him to the top of the standings having established a 20secs lead over Ricciardo with 16 laps remaining, only for his Mercedes' engine to suffer a rare failure as the race entered its closing stages.

A potentially pivotal moment in the championship fight between Hamilton and Rosberg, the unexpected twist came in a race where the defending champion appeared set to capitalise on a troubled afternoon for his main rival when he was tapped into a spin by Vettel at the first corner.

On a scorching day in Malaysia, Hamilton came into the race needing at least his first win since the German Grand Prix, but looked set to get more than he bargained for as Rosberg tumbled to the back of the field following his tangle with Vettel.

Prompted by the fast-starting Vettel being caught on the inside at turn one by Max Verstappen and out-braking himself, the German clipped the Mercedes coming across the apex to turn him around, breaking his front suspension and putting the Ferrari out on the spot.

Though he escaped without damage, Rosberg dropped to the back of the field, even if gained from Felipe Massa, Kevin Magnussen, Esteban Gutierrez and Daniil Kvyat all pitting ahea after the quartet collided with one another in the concertina effect of the Mercedes' spin.

As such, with the Virtual Safety Car deployed to clear Vettel's car, Hamilton led from Ricciardo, Sergio Perez, Kimi Raikkonen and Verstappen, though the latter would make swift progress up to third place on the restart.

With Hamilton gradually easing his lead out front as Rosberg steadily began making his way back up the order, a second VSC of the race on lap nine following a brake failure and crash for Romain Grosjean at the final corner would see Red Bull split strategies by putting Verstappen on another set of soft tyres.

As such, when Hamilton and Ricciardo pitted themselves on lap 21 and 22, Verstappen found himself in the lead but couldn't establish enough of a margin to make a difference when he pitted for hard tyres on lap 27 he would come out four seconds behind the Australian.

Rosberg, meanwhile, was enjoying a swift route up the order and already found himself in fifth by lap 20, but would come up against stern opposition in Ferrari's Raikkonen in their fight for fourth.

However, having gotten onto the tail of the Finn on lap 37, he pounced for a move on lap 39 with a bold pass down the inside of turn two having followed an outside line around turn one. The pair would clip front wheels though, leading to some damage to the Ferrari, contact that would earn Rosberg a ten-second penalty later in the race.

By the time the penalty was issued, however, the dynamic of the race had changed entirely after Hamilton's power unit expired just as he began lap 40, the Briton inconsolable on the radio as the fiery W07 coasted to a halt at turn one. A bitter end to an otherwise dominant race, his retirement would be compounded by the inadvertent effect of promoting Rosberg onto a net podium.

It would also leave Red Bull in an unexpected 1-2 position, Ricciardo ahead of Verstappen. Ironically, the pair had almost come to blows as they disputed second just a couple of laps before Hamilton's exit, Verstappen's fresher tyres allowing him to pull alongside through turn three, four and five, only for a similarly aggressive Ricciardo to cling on.

With Red Bull now looking at a first 1-2 since Brazil 2013, the team opted to pit both Ricciardo and Verstappen at the same time during the third Virtual Safety Car to clear Hamilton's car.

Allowing Ricciardo some breathing room in the final laps after the double stack, he protected a slim but untroubled 2.4s margin to the finish line to claim his fourth career win his first since the 2014 Belgian Grand Prix.

Rosberg, meanwhile, began the final phase of the race six seconds ahead of Raikkonen albeit now facing a ten-second penalty, but would pull out 13secs over the Finn to keep his third place.

A 'save' for Rosberg on what looked to be a tough day, the maximised result sees him extend his advantage over Hamilton to 23 points with only five races of the season remaining.

Behind Raikkonen, Valtteri Bottas made an unusual one-stop strategy work remarkably well as he surged from 11th to fifth position. However, with Felipe Massa failing to score and Sergio Perez and Nico Hulkenberg sixth and eighth, Force India has stretched his advantage over Williams in the battle for fourth overall to three points.

Between the Force India drivers, Fernando Alonso put in a superb drive from the back of the grid to finish seventh, the Spaniard capitalising on the carnage at the start to make up several positions before holding firm in the points.

A first double points' finish for McLaren since Monaco, Jenson Button secured a welcome ninth place finish in his landmark 300th race, while Jolyon Palmer is finally off the mark after his own risky one-stop strategy - aided by the three Virtual Safety Car periods - saw him finish tenth for Renault from 19th on the grid.

Elsewhere, Haas endured a shocking race as Grosjean's brake-induced retirement was compounded by Esteban Gutierrez having a wheel spear off his car on an out-lap.