After finishing the previous campaign with four wins in six races – his first victories in the top category – Bagnaia had endured a slow start this year, failing to even reach the podium prior to this weekend.
But a record lap in qualifying put the Ducati man on pole in Jerez, and he led from start to finish to kickstart his season.
Quartararo, starting in second, was Bagnaia's closest challenger, making a strong start and applying intense pressure for the first half of the race.
But Bagnaia was then able to open up a gap and enjoy a slightly more comfortable ride for his first win at this event, and fifth podium in his past seven entries across all categories.
Quartararo could at least be comforted by his now seven-point lead in the championship on a tough day for Alex Rins, who had been level at the summit but had to settle for 19th.
With Aleix Espargaro – now Quartararo's nearest challenger – completing the podium, the top three ended as they began, although the battle for third was a thriller.
Marquez eventually got past Miller with five laps remaining following a stunning move at Turn 5, which he made stick despite the pace of the Ducati.
But that manoeuvre opened the door for Espargaro, running in fifth, to come back at them, and he profited when Marquez went wide at Turn 13 and required an incredible save to stay on his bike, catching himself with his left elbow.
Espargaro was able to build a bigger gap, although Marquez at least passed Miller again for fourth, delivering the drama that was missing at the front of the race.
1. Francesco Bagnaia (Ducati Lenovo)
2. Fabio Quartararo (Monster Energy Yamaha) +0.285secs
3. Aleix Espargaro (Aprilia Racing) +10.977s
4. Marc Marquez (Repsol Honda) +12.676s
5. Jack Miller (Ducati Lenovo) +12.957s
6. Joan Mir (Suzuki Ecstar) +13.934s
7. Takaaki Nakagami (LCR Honda Idemitsu) +14.929s
8. Enea Bastianini (Gresini Racing) +18.436s
9. Marco Bezzecchi (Mooney VR46 Racing) +18.830s
10. Brad Binder (Red Bull KTM) +20.056s
1. Fabio Quartararo (Monster Energy Yamaha) 89
2. Aleix Espargaro (Aprilia Racing) 82
3. Enea Bastianini (Gresini Racing) 69
4. Alex Rins (Suzuki Ecstar) 69
5. Francesco Bagnaia (Ducati Lenovo) 56
1. Suzuki Ecstar 125
2. Aprilia Racing 109
3. Monster Energy Yamaha 107
4. Ducati Lenovo 98
5. Red Bull KTM 91