Australian Jack Miller rode to only his second MotoGP victory in Jerez on Sunday as Ducati team-mate Francesco Bagnaia finished second to take the overall championship lead.
Miller, who underwent surgery early in April, took the lead when pre-race championship leader Fabio Quartararo started to lose pace midway through the race.
On a track where Ducati had not won since 2006, Bagnaia followed Miller home to take the championship lead from Quartararo.
Italian Franco Morbidelli was third on a Yamaha.
Frenchman Quartararo finished 13th and doubled over, seemingly in pain, at the finish.
Miller started and finished his immediate post-race interview in tears.
"It's a flood of emotions: happy sad, everything," he said.
"I thought when Fabio went past OK he's got a bit better pace," Miller said. "I thought he was going to bolt."
"I didn't expect him to come back to me he did."
"He started to drop really off when I passed him."
"There were still 12-13 laps left and I was thinking that's a long time out in front by myself but I was able to do it."
Bagnaia followed Miller home to give Ducati the first two places and take the championship lead.
"I'm happy," he said. "This was a really tough track for us, so to finish one two is a really big result for us," he said.
Japanese rider Takaaki Nakagami (Honda-LCR) was fourth and Spanish world champion Joan Mir (Suzuki) was fifth.
Spaniard Marc Marquez, who after crashing his Honda in practice on Saturday, crashed again in the warm-up on Sunday, finished a creditable ninth in his second Grand Prix after nine months out with injury.
Morbidelli scored his first podium of the season.
"It was pretty easy," he said. "I just gave more than the maximum, always. I was really on the limit. I risk a lot. Finally we were rewarded. This podium feels just like a victory