The pair emerged as class of the field after a frantic opening to the Austrian Grand Prix and fought it out for victory, Dovizioso prevailing by 0.176s despite a desperate last-corner lunge by his rival.
However, a race-long battle with the Ducatis of Dovisizioso and Jorge Lorenzo ensued, and the reigning champion had to make do with second after the former passed him late in the race and held off his last-corner challenge.
Having won the last two Global Positioning System, three-time world champion Marquez has a 14-point lead in the standings over Maverick Vinales, who was fourth on Saturday with his Yamaha team-mate Valentino Rossi seventh.
Dovizioso, who was second in Austria to his then team-mate Andrea Iannone a year ago, took advantage of the battle between Marquez and Lorenzo to snatch the lead. However, that was just a temporary push as the Honda rider charged back into taking second place. On Lap 18, a slight error cost Marquez his lead and gave enough opportunity to Dovizioso to pass him.
Dovizioso then made it three-wide for the lead on the following straight and was even ahead at Turn 4, but ran wide, handing first place back to Marquez.
"On the last lap I was thinking about everything; the championship, I forgot a little bit", Marquez said.
Marquez lunged down the inside of the Italian, forcing both wide, but Dovizioso managed a better exit and clung on to win.
The session started with Yamaha's Valentino Rossi - who had struggled with illness on Friday and could only manage 12th in practices one and two - leading the early running. Finishing third was Dani Pedrosa as Honda dominated the podium.
Yamaha endured a disappointing afternoon with Maverick Vinales and Valentino Rossi taking the sixth and seventh spot, respectively.
Alvaro Bautista was a lonely eighth for Aspar Ducati, with Avintia Ducati's Loris Baz ninth.
KTM wildcard Mika Kallio beat last year's victor Andrea Iannone to the 10th spot.
The other KTMs did not pick up any points, with Pol Espargaro ruled out early after a startline collision.
Australia's Jack Miller crashed out on lap nine of the race.