Aspar rider Maximo Quiles secured his first-ever Moto3 victory by the smallest of margins in an instant classic at Mugello.
An ambitious last corner overtake saw the Spanish rider take his first win by just 0.006s over the line, winning his first race in just his fifth Grand Prix start.
Polesitter Alvaro Carpe maintained the lead going down into the first corner despite running wide, as team-mate Rueda retained second.
Scott Ogden made a good start from the front row and challenged Rueda for second, but ran wide a corner later and lost two positions to the Spaniard and David Almansa.
Coming down the start/finish straight for the first time, Almansa used the slipstream to head into the race lead with Angel Piqueras in second.
The polesitter returned to the fray and moved into the lead of the race, which he managed to hold despite the slipstream down the main straight.
Coming out of the first turn, contact between Ogden and Almansa saw the Spaniard’s race end in the gravel, as the stewards decided not to take action over the incident.
The riders kept jostling for position as the laps progressed, with Maximo Quiles joining the battle for the lead from 10th and Valentin Perrone amidst the battle despite being sent to the back of the grid.
The scraps continued, with Perrone and David Munoz making contact while fighting over the final podium position, causing the pair to drop further down the order.
Battles continued down the order and slight contact between Munoz and Guido Pini caused the Spaniard to run wide, with the knock-on effect causing Luca Lunetta and Adrian Fernandez to crash out of contention.
On Lap 10, Carpe relinquished the lead for the first time in five laps as Quiles headed to the front, with Perrone demoting the Spaniard to third.
Moto3 veteran Dennis Foggia then took command out front, as he led a race for the first time since his return to the class.
Just behind, contact between Joel Kelso and Pini saw the Italian crash out of the race, with many riders in the lead group forced to take action to avoid hitting the stricken Pini.
The leading group was split from a group of 19 to 12 riders, with Quiles taking charge at the front with five laps remaining.
Carpe used the slipstream to return to the lead, bringing Foggia back into contention for the race victory.
With two laps remaining, the battle for the win remained between 12 riders as Carpe and Foggia retained the top two positions.
Heading down the main straight for the final lap, it was Foggia who came out on top going into the first corner as he looked to keep hold of the position.
However, the aggressive moves continued from behind as the Italian was pressured by Carpe and team-mate Quiles.
Heading into the final corner, Quiles saw the opportunity and forced an overtake on Foggia as he took the lead, with Carpe demoting the Italian to third.
On the rundown to the line, it was Quiles who stole victory by 0.006s ahead of the fast-charging Carpe.
Foggia completed the podium in his home race, 0.066s behind team-mate and victor Quiles.
Championship leader Rueda finished fourth, as Munoz pipped Taiyo Furusato to the line in fifth.
Angel Piqueras took the flag in seventh ahead of Perrone, who progressed from last on the grid into eighth.
Kelso ended the race in ninth with Ryusei Yamanaka completing the top 10.
Nicola Carraro was promoted to 11th after Ogden received a three-second post-race penalty, with the Brit moved to 12th.
Jacob Roulstone was split from the lead group and defeated Cormac Buchanan on the run to the line for 13th.
Stefano Nepa rounded out the points finishers in 15th.