Vinales and Cortese were joined by Fenati in a three-bike breakaway in the closing stages as the two title chasers competed in a remarkable finale.
Team Italia rider Fenati pulled to the inside of the track and managed to inch ahead of Ajo KTM rider Cortese for second, but fell 0.020 seconds shy of beating Vinales over the line, with Cortese just 0.051s further back.
Another rising Italian star took fourth, as Gresini's Niccolo Antonelli beat Cortese's team-mate Danny Kent, Laglisse rider Efren Vazquez and Monlau's Alex Rins in another spectacular battle.
Jakub Kornfeil claimed eighth for Ongetta, ahead of Zulfahmi Khairuddin - who burst through from seventh on the grid to lead the first half-lap on his Ajo KTM. Veteran Hector Faubel (Aspar) completed the top 10.