Pedrosa, who almost quit the sport this year because of an arm injury, took the lead seven laps from the end.
Rossi's Yamaha team-mate and championship rival Jorge Lorenzo was third after suffering tyre problems.
Rossi now leads Lorenzo by 18 points in the standings with a maximum of 75 available from the final three rounds.
Only those two drivers can win the title, meaning Marc Marquez's two-year reign as world champion is over.
Pedrosa, whose career began in the 125cc class in 2001, had not won a MotoGP race since the Czech Grand Prix in August 2014 and missed three of the season's first four races after arm surgery.
"I couldn't go fast in the beginning," said the 30-year-old. "But at the end my pace was faster and could win the race. I am very happy."
Meanwhile, San Marino rider Alex de Angelis is in a "critical condition" with bleeding inside his brain, following a crash in practice on the eve of the race.
The 31-year-old is sedated in the intensive care unit of Dokkyo Medical University Hospital, with race doctor Michele Zasa stating an MRI scan had showed he had a brain haemorrhage.
De Angelis, who competes for Team e-motion Iodaracing, also fractured five vertebrae and two ribs, and suffered a slight fracture of the sternum and the left collarbone.
Meanwhile, British rider Danny Kent edged closer to winning the Moto3 title by finishing sixth in his race, one place ahead of main rival Enea Bastianini.
Kent now leads the Italian by 56 points with three races remaining.
The 21-year-old, from Chippenham, is attempting to become the first British world champion since Barry Sheene in 1977.
Spain's Dani Pedrosa claimed the 50th Grand Prix win of his career with victory over championship leader Valentino Rossi in the Japanese MotoGP.