Martin leapt into the lead on the opening lap but was quickly reeled in and passed by poleman Marquez, who looked on course for a first Gresini Ducati win.
But on lap nine of 12, Marquez fell off at Turn 9, just seconds after third to fifth-placed Alex Marquez, Enea Bastianini and Brad Binder slid off at Turn 5.
Maverick Vinales crashed at the same place on the following lap while running third, with several others all having front-end crashes through to the finish.
In all, 16 riders out of 25 made it to the chequered flag, but everyone from 12th down also suffered crashes at some stage.
Reigning champion Francesco Bagnaia was involved in a collision with Marco Bezzecchi and Brad Binder at Turn 1 on lap three which took the factory Ducati rider out.
Through all the chaos, Tech3 rookie Pedro Acosta found himself in second, while Yamaha’s Fabio Quartararo rose from 23rd on the grid to complete the podium.
Martin now leads the championship by 29 points from Acosta, while Bagnaia is 42 adrift.
Early rain threats came to nothing as the lights went out for the 12-lap Jerez sprint, with Binder jumping into the lead from fourth on the grid on his factory KTM.
Martin slotted into second ahead of Marquez, while Bagnaia found himself mired in sixth.
At Turn 9 Martin took the lead away from Binder, while Aprilia’s Aleix Espargaro became the first crasher in a dramatic sprint at Turn 8.
Jack Miller would slide off his KTM at the last corner at the end of the first lap, but would remount to finish 14th.
At the front, Marc Marquez overtook Binder at Turn 9 for second with a tough move. However, the KTM rider scythed past again into the last corner on the third tour.
This move let Alex Marquez come through on the pair of them, while Binder ultimately lost the most.
Marc Marquez repassed his Gresini team-mate and brother Alex Marquez for second at Turn 1, while Binder went to reclaim fourth as Marco Bezzecchi threw his VR46 Ducati up the inside of Bagnaia.
Bezzecchi ran wide and forced Bagnaia to open the door to Binder, who came steaming up the inside but connected with the factory Ducati rider and sent him down.
The incident was placed under investigation by the FIM stewards, but no further action was taken.
Through all this chaos, Martin had opened a 1.3s lead over Marc Marquez come the start of lap four – though the Gresini rider would close the Pramac GP24 down by the start of the seventh tour.
Marquez capitalised on a moment for Martin going through Turn 7 to line up a move into Turn 9, which he executed cleanly to move into the lead.
But on lap nine his hopes of a first win since Misano 2021 were dashed when he fell at Turn 9, doing so seconds after Alex Marquez, Binder and Bastianini had identical crashes at Turn 5.
Martin was released into a comfortable lead as a result, with the Spaniard taking his second sprint win of the year by 2.970s from Acosta.
Yamaha’s Quartararo was already enjoying a strong fightback from a career-worst 23rd on the grid as he circulated in ninth before the chaos that enveloped the end of the race unfolded.
After Vinales fell at Turn 5 while running third on lap 10, Quartararo found himself in an unlikely rostrum spot and fended off KTM wildcard Dani Pedrosa by 0.050s to secure third.
Franco Morbidelli completed the top five for Pramac Ducati, passing LCR Honda’s Johann Zarco at the last corner of the final lap before the Frenchman also tumbled off his bike.
Raul Fernandez was sixth for Trackhouse Racing as Marc Marquez recovered to ninth – though was forced to drop a spot for punting Honda’s Joan Mir wide at Turn 13 on lap 11.
Tech3’s Augusto Fernandez and Oliveira, who was shuffled down to ninth after another aggressive Marquez overtake, secured the final sprint points.
Mir was 10th, 0.135s outside of the points, with LCR’s Takaaki Nakagami 11th as Zarco, Fabio Di Giannantonio (VR46), Miller, Alex Rins (Yamaha) and Lorenzo Savadori (Aprilia) saw the chequered flag despite crashes.
Honda’s Luca Marini and Stefan Bradl were late fallers, as was Bezzecchi.