Andrea Dovizioso will start the Malaysian MotoGP from pole position having beaten the Yamaha riders in a wet qualifying session on Saturday.
After a dry start to the day, the rain came down in the build-up to FP4 with more light rain falling at the start of qualifying.
Dovizioso hit the front with a 2:11.511 while newly crowned World Champion Marc Marquez slotted into second place, 0.363s off the pace.
The riders stuck to the full wets as the newly resurfaced track did not dry out despite the rain abating.
On a second run Jorge Lorenzo moved up to second place and Valentino Rossi took third, knocking Marquez off the front row.
The action, though, was by no means over.
With light again rain falling in the final minutes Cal Crutchlow's front end washed away at Turn 11, Aleix Espargaro went down at Turn 9, and Rossi pipped Lorenzo to third.
None of the riders, though, were able to beat Dovizioso's P1 time. Rossi was 0.246s off the pace with Lorenzo a further 0.06s down.
Marquez finished in fourth place ahead of Crutchlow, who recovered from his crash to put in a late improvement, and Andrea Iannone.
Espargaro was seventh ahead of Maverick Vinales and Alvaro Bautista while Loris Baz, who like Crutchlow progressed through Q1, completed the top ten.
Pole no.2️⃣ of 2016 for #AD04 – the last one was at Assen!
— MotoGP™ (@MotoGP) October 29, 2016
1 Andrea DOVIZIOSO Ducati Team 2'11.485
2 Valentino ROSSI Movistar Yamaha MotoGP 2'11.731 0.246
3 Jorge LORENZO Movistar Yamaha MotoGP 2'11.787 0.302
4 Marc MARQUEZ Repsol Honda Team 2'11.874 0.389
5 Cal CRUTCHLOW LCR Honda 2'12.558 1.073
6 Andrea IANNONE Ducati Team 2'12.598 1.113
7 Aleix ESPARGARO Team SUZUKI ECSTAR 2'12.869 1.384
8 Maverick VIÑALES Team SUZUKI ECSTAR 2'12.981 1.496
9 Alvaro BAUTISTA Aprilia Racing Team Gresini 2'13.325 1.840
10 Loris BAZ Avintia Racing 2'13.452 1.967
11 Pol ESPARGARO Monster Yamaha Tech 3 2'13.707 2.222
12 Hector BARBERA Avintia Racing 2'13.973 2.488
13 Bradley SMITH Monster Yamaha Tech 3 2'12.898
14 Jack MILLER Estrella Galicia 0,0 Marc VDS 2'12.907
15 Danilo PETRUCCI OCTO Pramac Yakhnich 2'13.776
16 Stefan BRADL Aprilia Racing Team Gresini 2'13.850
17 Hiroshi AOYAMA Repsol Honda Team 2'14.179
18 Scott REDDING OCTO Pramac Yakhnich 2'14.433
19 Eugene LAVERTY Pull & Bear Aspar Team 2'14.769
20 Yonny HERNANDEZ Pull & Bear Aspar Team 2'14.786
21 Tito RABAT Estrella Galicia 0,0 Marc VDS 2'15.89