Ducati rider Marc Marquez won the Japanese Grand Prix at Motegi, finishing ahead of Jorge Martin to cut the championship deficit to two points.