MotoGP championship leader Marc had looked destined for his first defeat in eight rounds as Gresini Racing's polesitter Alex cruised towards what would have been a fairy-tale home victory for the Spaniard.
But drama struck at turn 10 when the younger Marquez brother lost his balance and slid off, leaving Marc to inherit the win in bittersweet fashion - his 14th sprint victory in 15 rounds.
Yamaha's Fabio Quartararo finished second while VR46 Racing's Fabio Di Giannantonio was third, but the day belonged to Marc, who has admitted in the past that, despite being on home turf, the circuit is not among his favourites.
"Of course, I'm happy for my victory for the Ducati team, we won the Constructors' Championship. But unfortunately, Alex crashed," Marc said.
"I already gave up because he was faster than me. When I gave up, maybe he relaxed a bit too much, and he crashed on turn 10.
"But he will have another chance tomorrow (in the race) because he has the best pace. Anyway, we are happy on a circuit that we are struggling."
The victory confirmed Ducati as the constructors' champions after their riders, across two teams, won all the sprints and 12 of 14 races this season.
The victory extended Marc's lead to 187 points, putting him within touching distance of sealing a seventh title on Ducati's home turf at next weekend's San Marino Grand Prix.
Alex had broken the lap record to take his first pole since April 2023, and he took the lead into turn one as Quartararo, Marc and KTM's Pedro Acosta gave no quarter in an aggressive battle for second.
Marc and Quartararo made contact twice on the opening lap and, although the Frenchman held his own, the powerful red Ducati was faster on the straight as Marc used the Frenchman's slipstream to move up to second.
"I think that to fight with both Marquez brothers, then Acosta, was a super fight," Quartararo said.
Di Giannantonio managed to get past Acosta, but the Italian had work to do to catch up with the lead group as the Marquez brothers slowly put distance between themselves and the rest of the pack.
Behind them, both Aprilias were brought down in separate incidents, with Franco Morbidelli taking out Jorge Martin while Fermin Aldeguer lost balance and crashed into Marco Bezzecchi, who seemed to have injured his arm in the crash.
Marc looked resigned to finishing second with Alex completely in control out front, having dominated the whole weekend, but his eyes must have lit up when his sibling slid off at turn 10.
Alex screamed in frustration, as did his entourage in the Gresini garage, and Marc surged into the lead. Although he had a scare himself on another turn, he recovered immediately to stay on his bike and race towards the chequered flag.
Acosta won a mini-battle of factory and satellite KTM bikes when he finished fourth ahead of Enea Bastianini and Brad Binder, while Johann Zarco finished seventh for LCR Honda.