The riders in all three classes gathered for a tribute before the race to Simoncelli - who was killed in the Malaysian MotoGP.
Stoner escaped a first-corner collision which saw four riders crash and somehow overtook Ben Spies on the final corner to win his 10th race of the year.
Simoncelli's Gresini team earlier saw Michele Pirro win the Moto2 race.
British rider Cal Crutchlow managed to finish fourth - the best finish of his MotoGP career - as he claimed the rookie of the year award.
The MotoGP riders started the race on slick tyres in difficult conditions as a light drizzle fell over some of the circuit, and there was instant drama as four riders crashed out at the first corner.
Alvaro Bautista clipped the back tyre of Andrea Dovizioso and slid off, skittling the bikes of Valentino Rossi, Nicky Hayden and Randy De Puniet in the process.Stoner relieved to win 'hairy' Valencia GP
All four riders were unhurt in the accident.
Stoner got away safely to lead from Dani Pedrosa and Spies, before Dovizioso battled through to take second.
Stoner backed off as the rain started to fall heavily and Spies moved up into second place, with the lead falling to 1.294 seconds with four laps remaining.
Spies then passed Stoner as the world champion ran wide, and the American looked certain to win his second race of the season.
But Stoner somehow made up the gap coming out of the final corner to win the final race of the 800cc era by just 0.015 seconds.
Stoner told BBC Sport: "I had a massive lead and was managing that but as soon as more rain came I wasn't willing to push and take risks.
"I made a mistake and went into neutral and Ben came past and rode a good few laps. I didn't know how I could get past him but I realised I could get a much better drive out of the last corner so I tried to get as close as I could.
"It was the last lap of the last race of the year so I thought, 'Let's just go for it' - and I got it. It was one of the hairiest races of my career."
Earlier, team Gresini rider Michele Pirro won an emotional Moto2 race.
Simoncelli's Gresini team were originally not going to compete in Valencia but decided to take part and Pirro duly won the race to leave team boss Fausto Gresini in tears on the pit wall. Stefan Bradl crashed out of the race but had already won the Moto2 championship.
Maverick Vinales won the final ever 125cc race as Nicolas Terol took the championship. The class will be replaced by the new Moto3 championship from next season.