Dani Pedrosa won an incident-packed Valencia MotoGP here on Sunday, the closing grand prix of the season and the last race of Casey Stoner's career.
Pedrosa, who started from pole on his Honda, was followed across the line by Yamaha's Katsuyuki Nakasuga with Stoner, Australia's 2011 world champion, competing for the final time before retirement, in third.
Jorge Lorenzo, who clinched the world title last month in Australia, crashed out with 17 laps of the race remaining.
In tricky conditions with the track drying after early rain, tyre selection was essential, with some of the riders starting on slicks and others on wet.
Pedrosa managed to avoid any mishaps to clinch his seventh win of the season to end up with 332 points in the riders standings, in second behind Lorenzo on 350, with Stoner bowing out in third place on 254 points.
Pedrosa, claiming his 45th career win, told the BBC: "I'm really happy because it was so difficult out there with the track drying up.
"I managed to catch Jorge, then I made a mistake, then he made one at the same point.
"It was very hard to keep focus towards the end as the gap (back to the chasing pack) was so big.
"This is a good way to finish the season."
Stoner's team marked the end of their rider's career with a sign hanging over the track wall saying: "Going fishing".
The Australian, reflecting on his last ever race, said: "I didn't want to take any risks out there in my last race, I was scared of crashing in these conditions.
"There were a lot of crashes today and it was difficult.
"I put on slick tyres but my eyes were dinner plates as I didn't want to take my bike off the dry patch.
"It's fantastic to end (my career) this way, a big thanks to everyone, to my supporters all these years, there are a lot worse ways to go out."
For Lorenzo his hopes of celebrating his second world title were undone by a spectacular spill.
The Spaniard, who set off on the front row in second on the grid, had slipped down the pack in the early laps before moving up through the field to lead after a flurry of pit stops to change to slick tyres.
Pedrosa, who crashed out in the last race in Australia to hand the title to Lorenzo, was racing in second, around four seconds behind.
With 17 laps to go Lorenzo's race came to a premature end when he lost control of his bike coming out of a bend, trying to overtake a backmarker.
Despite valiant attempts to stay onboard his bike went from under him, somersaulting through the air while the world champion came to grief on the trackside safety gravel.
Amazingly, he walked away unharmed, to leave Pedrosa in control.
Pedrosa was left with a commanding 26sec cushion over Yamaha's British rider Cal Crutchlow, who was robbed of the chance of a podium place when he parted company with his bike with only seven laps remaining.
That left Nakasuga, one of Yamaya's test riders, to claim second, 40sec adrift.
In all eight riders failed to complete.
The Moto2 race was won by world champion Marc Marquez with the Moto3 honours going to Britain's Danny Kent from his teammate and world champion Sandro Cortese.