Red Bull KTM Ajo’s Sandro Cortese took victory in a thrilling battle to the line with rival Maverick Viñales at the Grande Prémio de Portugal Circuito Estoril.