A thrilling last lap battle left Marquez with victory in sight, only to be out-dragged by Lorenzo on the final stretch.