Enea Bastianini took his first win in two years in a dramatic Catalan Moto3 Grand Prix, as championship contenders Jorge Martin and Aron Canet crash out.
Martin seized the advantage at the start and took the lead on the run into Turn 1, while Tatsuki Suzuki slotted in behind the Gresini rider and poleman Bastianini fell to fifth.
The top two were able to quickly break away from the chasing pack, who were engaged in a hard battle for third in the early stages.
By lap two, the gap between Martin and Suzuki and the rest stood at two seconds, with the latter sitting comfortably in Martin's slipstream as the pair continued to edge away from the chasing pack.
Bastianini moved into third at the start of lap nine, and began to drag the rest towards the top two, with their gap cut to just 1.6 seconds.
Drama struck a few corners into the ninth tour, as Martin crashed out at Turn 9. Suzuki was released into the lead, though Bastianini usurped him at the start of the next lap.
The lead swapped hands numerous times over the final laps, with Bastianini, championship leader Marco Bezzecchi, Jaume Masia and a resurgent Nicolo Bulega all taking turns running at the head o the pack.
The podium group downsized in dramatic fashion in the final five laps, with Albert Arenas wiping out Canet and Bulega at Turn 4 on lap 16, while Masia collected Andrea Migno at Turn 1 two tours later as the former attempted to avoid a collision with Bezzecchi under braking.
The chaos on lap 18 allowed John McPhee to move into the lead on his CIP KTM, which he reclaimed at Turn 5 a lap later after Prustel GP's Bezzecchi briefly snatched it back.
Bastianini moved back into the lead at the start of the final lap, and held a charging Gabriel Rodrigo and Bezzecchi at bay to claim his first victory since the 2016 Japanese Grand Prix.
Bezzecchi stole second away from podium debutant Rodrigo on the run to the line, and now holds a 19-point advantage over Fabio Di Giannantonio, who recovered to eighth from 26th after running off track at Turn 5 in the early stages.
McPhee held onto fourth for his first top 10 result of the season ahead of Suzuki, while Alonso Lopez claimed sixth after Jakub Kornfeil was hit with a 1.6s time penalty for exceeding track limits.
Kaito Toba was promoted to seventh as a result, with Di Giannantonio, Dennis Foggia and widcard Raul Fernandez completing the top 10, while Kornfeil ended up 11th.
Martin's third crash in four races means he now slips 23 points adrift of Bezzecchi in third in the standings.
Tony Arbolino, Kazuki Masaki, Marcos Ramirez, Darry Binder and Ayumu Sasaki – who was a factor in the podium fight early on – added their names to the retirements list.