Miller's other MotoGP win was in the 2016 Dutch Grand Prix
Australia's Jack Miller claimed his second MotoGP victory by winning the Spanish Grand Prix.
His Ducati team-mate Francesco Bagnaia finished second to take the overall championship lead.
Miller took the lead when pre-race championship leader Fabio Quartararo started to lose pace midway through the race.
Yamaha's Quartararo finished 13th and Franco Morbidelli was third.
"It's a flood of emotions: happy sad, everything," said Miller, whose previous win came at Assen in 2016.
Portuguese Grand Prix winner Quartararo recovered from a slow start to open up a two-second advantage at the front but a bike issue saw his pace drop significantly, allowing Miller to snatch the lead with 10 laps remaining.
"I thought when Fabio [Quartararo] went past OK he's got a bit better pace, I thought he was going to bolt.
"I didn't expect him to come back to me but 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."
Spanish Grand Prix
1. Jack Miller (Aus) Ducati 41mins 5.602secs
2. Francesco Bagnaia (Ita) Ducati +1.912secs
3. Franco Morbidelli (Ita) Yamaha +2.516secs
4. Takaaki Nakagami (Jpn) Honda +3.206secs
5. Joan Mir (Spa) Suzuki +4.256secs
6. Aleix Espargaro (Spa) Aprilia +5.164secs
7. Maverick Vinales (Spa) Yamaha +5.651secs
8. Johann Zarco (Fra) Ducati +7.161secs
9. Marc Marquez (Spa) Honda +10.494secs
10. Pol Espargaro (Spa) Honda +11.776secs
World Championship standings
1. Francesco Bagnaia (Ita) Ducati 66pts
2. Fabio Quartararo (Fra) Yamaha 64
3. Maverick Vinales (Spa) Yamaha 50
4. Joan Mir (Spa) Suzuki 49
5. Johann Zarco (Fra) Ducati 48