Honda rider Stoner, who sealed his second world crown at Phillip Island last month, snatched victory in Spain by the closest margin of the year from American Ben Spies.
Spies was just 0.015 seconds behind on his Yamaha as the flag fell in light rain, with Italian Andrea Dovizioso third on a Honda to finish third in the championship.
Stoner’s win came despite uncertainty, a key error and with the spectre of the late Marco Simoncelli clouding the event.
Simoncelli, who died in the second last race in Malaysia last month, was remembered sombrely at the track while seven-times world champion Valentino Rossi rode with half of his helmet painted in his friend’s colours as a tribute.
Unfortunately, Rossi, his Ducati team-mate Nicky Hayden and Randy de Puniet had to retire after a crash at the first turn.
Stoner admitted to some nervous moments and agreed he was lucky to clinch the win, which gave him his 16th podium of the season – equalling the record for most in a season held previously by Rossi and Yamaha’s Jorge Lorenzo.
“My heart was in my throat,” Stoner said of the increasingly slippery track.
“We did such a good job all the race and then it started to rain heavily.
“Being the first one to arrive to the conditions on the track, I wasn’t sure how hard to push so I slowed up to ensure I finished the race and I thought if they come past I can stay with them.
“Then coming onto the back straight I made a slight mistake when I went into neutral instead of first gear and Ben came past me,” he said.
Stoner said he feared his error had handed Spies the win but clung on in the knowledge he could make one final lunge at the line.
“I tried to stay with him but he was riding very well, fast and smooth and he looked confident in the conditions, more so than me,” Stoner said.
“In the first half of the final lap he made a nice gap but I knew we were quick in the second half of the lap.
“I thought to myself, we haven’t been able to take any risks all season, this is the time to take one and see what we can do. I knew I had a better exit line out of the final turn and I kept my head down and went for the line.
“It’s amazing to win this on the finish line, I’ve had it done to me in the past a few times but I’ve never done it to anyone else. I’m sorry for Ben, he rode a great race.”
Before the race all riders across all classes paid their respects to Simoncelli in a tribute lap led by MotoGP legend Kevin Schwantz riding the Italian’s No.58 Honda bike.
The Honda team will return to the Valencia track on Tuesday in the first official testing day for 2012.
Dani Pedrosa and Stoner will take part in the two day test with high hopes of continuing their superiority.