Marquez, 21, on his Honda, raced through from third on the grid to take the lead from Valentino Rossi on the 18th lap and overcame a late challenge from Dani Pedrosa to beat the record that previously held by Rossi.
Pedrosa was fastest in practice but made a poor start and Jorge Lorenzo briefly took the lead before Rossi, on his Yamaha, came through on the third lap.
The veteran seven-times world champion held off the challenge from Marquez but the Spaniard finally found a gap to overtake.
In a dramatic finale, Pedrosa briefly took the lead on the final lap before Marquez responded. Pedrosa then made another attempt which failed and Rossi stole through to take second.
"I was a bit worried before the start as I was further back on the grid and I needed to get my gear changes right going into the first curve," Marquez told reporters.
"From there I just tried to push forward as much I could to get to the front and then hang on. Now I will try to keep this run going as long as I can."
He leads the driver's championship with 175 points, ahead of Rossi on 117 points and third-placed Pedrosa on 112 points.
Marquez's brother Alex won the Moto3 class earlier and in a clean sweep for Spain, Esteve Rabat came first in the Moto2.
- Sports & Recreation
- Dani Pedrosa
- Valentino Rossi