Three Spanish riders filled the podium, with Suzuki's Alex Rins second and Yamaha's Maverick Vinales third.
Marquez now has 140 points after his fourth win of the season to 99 for Yamaha's Italian Valentino Rossi, who finished fifth, and Vinales on 93.
Rossi announces decision to retire at end of season
Only 4.462 seconds separated Marquez from seventh placed finisher Jorge Lorenzo, winner of the previous two grands prix for Ducati, in a hotly-contested 26-lap race at the Assen circuit.
MotoGP star Jason Dupasquier dies after crash
Quartararo sets lap record to take pole at Italian GP