Jorge Lorenzo struck the final blow in a dog fight with fellow Spaniard Marc Marquez, overtaking at the start of the final lap on Sunday to win the Austrian MotoGP.
Ducati's Lorenzo and Marquez, on a Honda, traded first place over the closing laps before Lorenzo powered past on the home straight and then held off Marquez on the next corner to pull away to win.
Lorenzo, who will be moving to Honda next season, said he made an effort to conserve his tyres in the early part of the race.
"Ten laps to the end, I decided to attack," Lorenzo said immediately after the race. "I was stronger in some areas, like uphill, he was stronger on the second corner. When I passed him, I gave everything and pushed to the limit. One of my best victories."
Marquez could afford to savour the battle because his closest rival in the standings, Italian veteran Valentino Rossi, started from 14th on the grid and could only climb to sixth.
The Red Bull Ring remains the only circuit in the championship where Marquez has not won, with Ducati taking all three races since MotoGP returned to the track in 2016.
"This race I enjoyed," Marquez said. "There was a moment when I thought I could lose the two Ducatis, but they came back.
"I gave everything, everything. I would try to defend my position but he did it to me on the straight. Great show."
Marquez now leads the standings by 59 points as he closes in on a fifth top-class world title.
Lorenzo jumped to third overall, one point ahead of Andrea Dovizioso who finished third on the other Ducati. The Italian, who won last week in Brno, could not quite keep up with the pace of the two leaders.
"I was third and I couldn't ride in the way I wanted," Dovizioso said. "Three riders using three different tyres and I used a little too much tyre. I don't know maybe it was the wrong tyre. But anyway, another Ducati won."
In Moto2, Italian Francesco Bagnaia overtook Portuguese Miguel Oliveira on the final corner to regain first place in the standings.
Oliveira (KTM) started two points ahead of Bagnaia (Kalex) and grabbed an early lead.
The pair pulled clear of the field with Bagnaia on Oliveira's rear wheel trying to find a way past.
The Italian briefly grabbed the lead with five, four and two laps to go, but each time the Portuguese rider struck back on the next corner.
The same thing happened on the last lap, but Bagnaia then conjured one last attack, and this time Oliveira could not reply.
"When it was possible to overtake him and when I did on the last corner it was amazing," Bagnaia said.
The victory means Bagnaia leads Oliveira by three points in the standings.
"It sucks a little bit to lose like this," said Oliveira.
In Moto3, Italian teenager Marco Bezzecchi won to extend his lead over injury-stricken Jorge Martin at the top of the riders' standings.
KTM rider Bezzecchi, 19, who started from pole for the first time in his career, held off Enea Bastianini and Martin to move 12 points clear of the Spaniard in the championship race.
Martin, despite racing with a broken wrist, finished third in a brave ride to keep his hopes of a first world title alive.
It was an incredible podium finish from the 20-year-old Honda man, who missed the Czech Grand Prix last weekend after crashing in practice.
Jorge Lorenzo won a thrilling Austrian MotoGP while Ducati teammate Andrea Dovizioso could only finish third.
Jorge Lorenzo showed the Ducati power as he won in Austria.