The Spaniard overtook Marco Bezzecchi on the penultimate lap to win the race, while Ai Ogura secured Japan's first podium finish for 14 years.