Marc Marquez claimed a last lap victory in a pulsating Australian MotoGP, after a gripping four-way dogfight left riders and fans gasping for breath.