Casey Stoner took victory in a thrilling 250cc Portuguese Grand Prix after an audacious last lap pass on fellow Aprilia rider Randy de Puniet.