Andrea Dovizioso won a dramatic rain-lashed, red-flagged Valencia MotoGP finale, which saw just 15 finishers and a debut podium for KTM courtesy of third-placed Pol Espargaro
Sunday's race was one of two halves, as worsening rain led to myriad crashes and an eventual red flag period to allow track conditions to improve.
Suzuki's Alex Rins held a commanding lead at one stage of the opening 14 laps, the Spaniard over four seconds clear of Ducati's Dovizioso at one stage.
As the rain intensified, the Ducati rider began to reel in Rins, with Yamaha's Valentino Rossi closing in also despite starting from 16th.
Rossi and Dovizioso traded the lead before the stoppage, after a mistake from Rins at Turn 11.
World champion Marc Marquez was the only rider to go with the medium wet rear, and crashed while battling for the podium at Turn 9 on the seventh lap, with brief third-place runner Espargaro coming off his KTM moments before.
Maverick Vinales also fell foul of the conditions at Turn 14, as were the Marc VDS pair Tom Luthi and Franco Morbidelli, Pramac duo Danilo Petrucci and Jack Miller, Aleix Espargaro [Aprilia] and the sister KTM of Bradley Smith.
The race was restarted over 14 laps after a lengthy delay, with only 17 starters, with Rins taking the lead into the first turn after launching from pole.
Dovizioso powered past the Suzuki on the run into Turn 1 on the second tour, and began to break away from the chasing pack, opening up his lead to over two seconds with five laps remaining.
Rins quickly came under pressure from Rossi, and fell prey to the Yamaha rider at Turn 4 on lap seven, while Dovizioso continued to extend his advantage at the front.
Rossi looked settled in second as the race reached its closing stages, but fell at Turn 12, gifting Rins second once more and allowing KTM's Espargaro – who rejoined after his first crash and took the restart – to move into podium contention.
Dovizioso remained upright and unopposed to the flag to claim his fourth win of the year, while Rins crossed the line second for his fifth podium of the season.
Espargaro responded to a late charge from Ducati wildcard Michele Pirro to secure his and KTM's first MotoGP podium in third place.
Dani Pedrosa ends his racing career with a fifth-place finish and top Honda honours, with LCR's Takaaki Nakagami heading Tech3's Johann Zarco, Smith [KTM], Stefan Bradl [LCR] and the sister Tech3 of Johann Zarco.
Scott Redding's MotoGP career concludes with an 11th-place on the sole-remaining Aprilia, while Rossi rejoined to finish 13th behind Jorge Lorenz on his Ducati farewell.
Karel Abraham [Nieto] and Jordi Torres [Avintia] were the last of the finishers and took the remaining two points, with the World Superbike-bound Alvaro Bautista falling from his final premier class appearance.