Katsuyuki Nakasuga was second on his Yamaha, more than 37 seconds behind, while retiring two-time world champion Casey Stoner earned his 69th career MotoGP podium with a third-place finish in his final race.
Pedrosa had won pole position in Saturday's qualifying, but he opted to take the pit-lane start penalty for a last-minute change of tires due to a rain shower that slicked the 4km Comunitat Valenciana track.
The Spaniard made quick work of the field to steer his Honda into second place before taking over the lead when Lorenzo went off on his Yamaha after hitting a wet patch with 17 laps to go.
"It was a thrilling race," Pedrosa said. "I had never started from pit lane before, but after the warm-up lap I had a moment of inspiration when I just knew I needed to change tires.
"It's fantastic to win the last race of the season."
It was Pedrosa's 22nd career MotoGP victory. He finished the championship in second place behind Lorenzo, but his seven wins on the season gave him one more than his fellow Spaniard. Lorenzo ended with 350 points. Pedrosa had 332, while Stoner was a distant third with 254.
Seven of 21 riders failed to finish the accident-filled race.
Stoner turned in a final lap to salute the fans.
"I am a little disappointed for not being able to win this race, but it's a nice way to retire getting on the podium" Stoner said. "Thanks to all my team, my supporters and my sponsors for all these years."
The Australian rider is retiring at 27 after winning the MotoGP title with Ducati in 2007 and his current Honda team in 2011. He won 38 MotoGP races since joining the circuit full-time in 2006.
In Moto2, Marc Marquez capped his world championship season with a win after starting from second place. Julian Simon and Nicolas Terol completed the all-Spanish podium.
Marquez finished the season with 324 points. Fellow Spaniard Pol Espargaro was second with 268 points, while Andrea Iannone of Italy was third with 193.
In the Moto3 class, British rider Danny Kent passed world champion Sandro Cortese of Germany on the last lap. Cortese finished second, with Zulfahmi Khairuddin of Malaysia in third.
Cortese finished the season with 325 points. Luis Salom was runner-up with 214, with fellow Spaniard Maverick Vinales in third place with 207.
Results of the Valencia motorcycling Grand Prix here on Sunday:
MotoGP
1. Dani Pedrosa (ESP/Honda) 48min 23.819sec, 2. Katsuyuki Nakasuga (JPN/Yamaha) at 37.661s, 3. Casey Stoner (AUS/Honda) 1:00.633, 4. Alvaro Bautista (ESP/Honda) 1:02.811, 5. Michele Pirro (FTR Honda) 1:26.608, 6. Andrea Dovizioso (ITA/Yamaha) 1:30.423, 7. Karel Abraham (CZE/Ducati) 1:31.789, 8. Danilo Petrucci (ITA/Ioda Suter) 1 lap, 9. James Ellison (GBR/Aprilia) 1 lap, 10. Valentino Rossi (ITA/Ducati) 1 lap, 11. Aleix Espargaro (ESP/Aprilia) 1 lap, 12. Randy de Puniet (FRA/Aprilia) 2 laps, 13. Hiroshi Aoyama (JPN/Kawasaki BQR) 2 laps, 14. Colin Edwards (USA/BMW Suter) 3 laps
Moto2
1. Marc Marquez (ESP/Suter) 48min 50.706sec, 2. Julian Simon (ESP/Suter) at 1.256, 3. Nicolas Terol (ESP/Suter) 11.372, 4. Thomas Luthi (SUI/Suter) 13.006, 5. Dominique Aegerter (SUI/Suter) 13.825, 6. Jordi Torres (ESP/Suter) 27.911, 7. Mikka Kallio (FIN/Kalex) 36.338, 8. Pol Espargaro (ESP/Kalex) 38.335, 9. Toni Elias (ESP/Kalex) 39.419, 10. Esteve Rabat (ESP/Kalex) 39.476
Moto3
1. Dany Kent (GBR/KTM) 45min 05.891sec, 2. Sandro Cortese (GER/KTM) at 0.056s, 3. Zulfahmi Khairuddin (MAL/KTM) 0.114, 4. Brzad Binder (RSA/Kalex KTM) 0.431, 5. Hector Faubel (ESP/FTR Honda) 4.371, 6. Louis Rossi (FRA/FTR Honda) 7.605