Ducati rider Andrea Dovizioso breathed new life into the MotoGP championship on Sunday, edging Marc Marquez in a ferocious duel to win a rain-soaked Japanese Grand Prix in Motegi.

Dovizioso snatched the lead from championship leader Marquez in a dramatic last lap in appalling conditions after the Spaniard made a rare mistake when rounding a corner.

The Italian's nerve-jangling win by 0.249 seconds trimmed the Honda rider's lead to 11 points with three races left in the season.

Danilo Petrucci finished third on a non-works Ducati, his fourth podium for the season, while Maverick Vinales' faint title hopes were all but extinguished after a disappointing ninth for Yamaha.

Spaniard Vinales heads to the next round at Phillip Island in Australia 41 points adrift of three-times MotoGP champion Marquez, who improved to 244 points in the title race.

Defending champion Marquez looked to have it won after he burned past Dovizioso with three laps left but he gave up precious momentum on the final lap with a slide at turn eight.

Thrown from his seat and all but crashing, Marquez did well to regain control but the error allowed Dovizioso enough ground to make a comeback for his fifth win of the season.

"The rear tyre was completely gone," Dovizioso said.

"But he did a mistake so I was able to catch him and I did a perfect corner at turn 10."

Marquez all but brushed Dovizioso's rear wheel as he attacked at the last corner but could find no way through.

"It was an amazing race, I mean the two guys that are fighting for the championship are fighting to the last corner," said Marquez.

"I did a few mistakes especially at turn eight, I lose a lot."

Suzuki savoured an encouraging weekend, with Andrew Iannone and Alex Rins finishing fourth and fifth respectively.

Three-times MotoGP champion Jorge Lorenzo fought to the front briefly in the early laps but faded to sixth for Ducati, while Italian great Valentino Rossi's forgettable weekend ended mid-race with a fall.