Pedrosa had taken the lead from Lorenzo off the line, but he lost the place at the second corner.
Lorenzo and Pedrosa then pulled away from the rest of the field until lap six, when the Honda rider made it back into the lead with a move into the Dry Sack hairpin.
From there, Pedrosa pulled away as Lorenzo's attention switched to rookie Marquez, who had dealt with a fast starting Valentino Rossi in the early laps to get up to third.
Marquez seemed to back off after a few failed attempts at taking second place, but he came on strong again in the closing stages to get back onto the reigning champion's tail.
The 20-year-old failed with a lunge into Dry Sack on the final lap, where he ran wide and allowed Lorenzo to hang onto the place.
But Marquez closed back up in the following corners to get a run into the final hairpin - which has been renamed after Lorenzo - to make a last gasp attack.
As Marquez dived up the inside, Lorenzo tried to hang on around the outside and the pair made contact, with Lorenzo getting pushed off the track and having to settle for third place.
Behind them, Rossi took a lonely fourth, while Cal Crutchlow fought off Alvaro Bautista to take fifth place.
Behind Nicky Hayden in seventh, his Ducati team-mate Andrea Dovizioso had a battle with the CRT bike of Aleix Espargaro for eighth place.
Espargaro briefly got ahead of the works Ducati, but he eventually had to settle for ninth.