Ducati's Andrea Dovizioso stole the Japanese Grand Prix from Marc Marquez at Honda's home circuit on Sunday, cutting the Spanish rider's championship lead to just 11 points.

Dovizioso took the race lead from Marquez for the first time with six laps to go at a wet Motegi Twin Ring, and the Italian rider was able to come out on top of a wild back-and-forth battle with a final-lap move, leading the reigning world champion home by 0.249 seconds.

Danilo Petrucci claimed third after leading the early stages of the race while Yamaha's Maverick Vinales, who sits third in the championship, closed out a poor weekend at the Tochigi Prefecture circuit by finishing ninth.

"I am so happy, it was very difficult, the grip was very low and the drop (off) of the rear tire was so high," said Dovizioso. "We did a great job from the first practice and thank you to the team because we are very strong."

The last lap saw Marquez at the front and in the best position to take the win, but a mistake which almost threw him off his Honda gave Dovizioso a small chance, and he took it.

"I knew I have an (overtaking) chance in the back straight, turn 11, but it was too far, he was pushing really hard and the tire was finished," said Dovizioso.

"But he did a mistake and I was able to catch him. I did a perfect corner in turn 10 and was able to brake really hard."

Marquez rued the small mistake, saying it probably cost him the win.

"I did a few mistakes and, especially in turn 8, I lost a lot...I knew the Ducati would be faster, even on the braking point they were faster, but I try on the last corner," he said.

"It was an amazing race, the two guys who are fighting for the championship, fighting until the last corner...In this circuit I already expected him to be very, very strong, but now we are going to (the Australian GP at) Phillip Island and maybe it can be different."

Yamaha rider Katsuyuki Nakasuga was the best Japanese finisher in 12th, a minute behind the winner, while Hiroshi Aoyama was the last finisher.

In Moto2, Japan's top class-bound rider Takaaki Nakagami scampered from pole position and led for much of the race before being pushed off the podium by eventual winner Alex Marquez, his Spanish counterpart Xavi Vierge and Malaysia's Hafizh Syahrin. Nakagami eventually drifted to sixth.

Romano Fenati topped an all-Italian Moto3 podium to cut into the lead of championship front-runner Joan Mir. Niccolo Antonelli was second, Marco Bezzecchi third.

Japan's best finisher in Moto3, Tatsuki Suzuki, crossed the line fourth, by far a career-best result for the 20-year-old Honda rider.