Honda's Marquez immediately lost his pole advantage at the start, beaten away by the Ducatis of front row partners Andrea Iannone and Andrea Dovizioso.
The championship leader then fell right back to sixth during a busy first lap, losing ground when the determined Jorge Lorenzo attacked both works Hondas and moved his Yamaha up to third.
Eager to make an early break, Lorenzo overtook the two leading Ducatis in a single move on lap two and then quickly pulled a one-second lead over the pack.
But despite Lorenzo's early pace, Pedrosa would prove to be the man to beat.
Although he made slightly slower progress past the Ducatis, once into second he swiftly destroyed Lorenzo's lead and then overtook him on lap five of 22.
Lorenzo never let Pedrosa get more than 1.8s ahead, and closed his lead down to under a second on the final lap, but the Honda rider had the race under control and took his first win since the 2013 Malaysian Grand Prix in October last year.
Marquez had a spectacular battle with Iannone - in which they exchanged places four times in half a lap and hit each other twice in the process on his way back through to third, which is where his charge stalled.
Rossi came back at him, overtaking the Honda at half-distance and then pulling away, leaving Marquez to trail home a muted fourth.
It was the first time Marquez had ever finished a MotoGP race off the podium, with last year's crash at Mugello and disqualification at Phillip Island the only other times he has missed a rostrum spot.
Iannone and Dovizioso continued to battle frantically for top Ducati honours all race, with the Pramac man finally beating the works rider over the line to take fifth by 0.195s.
Stefan Bradl, the battling Aleix Espargaro and Bradley Smith, and Alvaro Bautista completed the top 10.
Pol Espargaro and Cal Crutchlow both crashed out.
Scott Redding defeated the third works Ducati of Michele Pirro in a fight for 11th, with fellow Briton Leon Camier getting a point for 15th, narrowly losing out in a long fight with home favourite Karel Abraham.
1 Dani Pedrosa Honda HRC 42:47.800
2 Jorge Lorenzo Yamaha Factory +00.410
3 Valentino Rossi Yamaha Factory +05.259
4 Marc Márquez Honda HRC +10.454
5 Andrea Iannone Ducati Pramac +17.639
6 Andrea Dovizioso Ducati Team +17.834
7 Stefan Bradl Honda LCR +23.819
8 Aleix Espargaró Suter Forward +29.621
9 Bradley Smith Yamaha Tech 3 +30.364
10 Álvaro Bautista Honda Gresini +37.639
11 Scott Redding Honda Gresini +55.604
12 Michele Pirro Ducati Team +56.727
13 Hiroshi Aoyama ART Aspar +56.908
14 Karel Abraham Ducati Cardion AB +01:04.135
15 Leon Camier ART Aspar +01:04.902
16 Alex de Angelis Suter Forward +01:20.666
17 Héctor Barberá Blusens Avintia +01:24.282
18 Mike Di Meglio Blusens Avintia +01:27.436
19 Broc Parkes ART Bird +01:38.867
20 Danilo Petrucci Ioda Racing at 2 laps (DNF)
21 Cal Crutchlow Ducati Team at 15 laps (DNF)
22 Pol Espargaró Yamaha Tech 3 at 16 laps (DNF)
23 Michael Laverty ART Bird at 16 laps (DNF)
24 Yonny Hernández Ducati Pramac at 17 laps (DNF)
- Sports & Recreation
- Jorge Lorenzo
- Andrea Iannone
- Andrea Dovizioso