Italian Dovizioso is still 58 points behind five-time world champion Marquez despite pipping the Honda rider on the final lap to gain his first race win since the season opener in Qatar.
"I didn't think I could overtake on the last corner but it was the last one and I absolutely had to try," Dovizioso, 33, said.
"I felt incredibly strong at that point and sometimes you have to try something crazy."
Marquez, who is yet to win in Austria during his illustrious career, praised Dovizioso's performance.
"I'm happy because I finished second, of course we missed the last corner but I was sliding a lot on the rear tire," Marquez told broadcaster BT Sport.
"Dovi did an incredible job and at the moment we are leading by 58 points, so we have to continue on the same way."
Yamaha's Fabio Quartararo completed the podium and Australian Jack Miller was one of four riders who fell during the race.
Seven-time MotoGP world champion Valentino Rossi was fourth, his best result since finishing second in the US in April, but he is a whopping 127 points behind Marquez ahead of the British Grand Prix at Silverstone on August 25.
Earlier on Sunday South African Brad Binder celebrated his 24th birthday in style with success in the Moto2.
The KTM rider was all smiles after ending a winless spell stretching back to Australia in October last year.
"I can't imagine a better day than winning on my birthday at KTM's home track," the 2016 Moto3 champion beamed.
Binder crossed the line with a 0.330 advantage over Alex Marquez, who moved on to 181 points at the top of the Moto2 championships standings, a lead of 43 points over Thomas Luthi.
Binder's success came just after Austrian manufacturer KTM had announced they were withdrawing from the Moto2 championship at the end of this season to plough all their resources into MotoGP in an initial five-year deal.
That will suit Binder, who is graduating to the premier category in 2020.
Marquez' second place on the podium was hard earned.
The brother of MotoGP world champion Marc Marquez had started from 11th on the grid but managed to avoid a series of crashes that eliminated Japan's pole sitter Tetsuta Nagashima, Spain's Xavi Vierge, Australian Remy Gardner and Italian duo Enea Bastianini and Luca Marini.
"The conditions were very difficult and treacherous with a very slippery circuit," he said.
The Moto3 race was won by Italian Romano Fenati for Honda, his first victory since being banned for grabbing a break leaver of fellow rider Stefano Manzi last September.
Austrian MotoGP results and standings on Sunday:
1. Andrea Dovizioso (ITA/Ducati) 39min 34.771sec, 2. Marc Marquez (ESP/Honda) at 0.213, 3. Fabio Quartararo (FRA/Yamaha-SRT) 6.117 4. Valentino Rossi (ITA/Yamaha) 7.119, 5. Maverick Vinales (ESP/Yamaha) 8.674, 6. Alex Rins (ESP/Suzuki) 8.695, 7. Francesco Bagnaia (ITA/Ducati-Pramac) 16.021, 8. Miguel Oliveira (POR/KTM) 16.206, 9. Danilo Petrucci (ITA/Ducati) 17.350, 10. Franco Morbidelli (IRA/Yamaha-SRT) 20.510, 11. Takaaki Nakagami (JPN/Honda) 22.273, 12. Johann Zarco (FRA/KTM) 25.503, 13. Stefan Bradl (GER/Honda) 31.962, 14. Aleix Espargaro (ESP/Aprilia) 34.741, 15. Karel Abraham (CZE/ Ducati) 48.109
Did not finish (selected):
Jack Miller (AUS/Ducati)
MotoGP standings (after 12 of 19 races)
1. Marc Marquez (ESP/Honda) 230 points, 2. Andrea Dovizioso (ITA/Ducati) 172, 3. Danilo Petrucci (ITA/Ducati) 136 4. Alex Rins (ESP/Suzuki) 124 5. Valentino Rossi (ITA/Yamaha) 103
1. Honda 236 pts, 2. Ducati 202, 3. Yamaha 179, 4. Suzuki 141, 5. KTM 69, 6. Aprilia 47
1. Brad Binder (RSA/KTM) 37min 24.963sec 2. Alex Marquez (ESP/Kalex) 0.330, 3. Jorge Navarro (ESP/Speed Up) 1.839, 4. Lorenzo Baldassarri (ITA/Kalex) 2.183, 5. Augusto Fernandez (ESP/Kalex) 3.303,
Moto2 standings (after 12 of 19 races)
1. Alex Marquez (ESP/Kalex) 181 points, 2. Thomas Luthi (SUI/Kalex) 138 3. Jorge Navarro (ESP/Speed Up) 126 4. Augusto Fernandez (ESP/Kalex) 121 5. Lorenzo Baldassari (ITA/Kalex) 115
1. Romano Fenati (ITA/Honda) 37min 50.135sec, 2. Tony Arbolino (ITA/Honda) at 1.097, 3. John McPhee (GBR/Honda) 1.105, 4. Celestinio Vietti (ITA/KTM) 1.120, 5. Marcos Ramirez (ESP/Honda) 6.789
Moto 3 standings (after 12 of 19 rounds)
1. Lorenzo Dalla Porta (ITA/Honda) 155 points, 2. Aron Canet (ESP/KTM) 154, 3. Tony Arbolino (ITA/Honda) 113, 4. Niccolo Antonelli (ITA/Honda) 105, 5. Marcos Ramirez (ESP/Honda) 89