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.

In the last month, prices went up by 1.7%, said the Halifax, bringing the average price of a home to Â£208,286.
However, other lenders, such as the Nationwide measure, put the rate of increase much lower.
Last month, it said prices rose by 4.5% in 2015, less than half the Halifax estimate.
Halifax's housing economist, Martin Ellis, said one reason for the sharp increase was the continuing shortage of property for sale.
"This situation is unlikely to change significantly in the short term, resulting in continuing upward pressure on prices," he said.
The last time UK house prices rose so quickly was in 2006, when values soared by 9.9%.
The 9.5% increase in 2015 was way ahead of experts' predictions a year ago.
Martin Ellis himself predicted that prices would rise by between 3% and 5%, while most expected a figure around 4%.
Newham, in East London, was the town with the largest increase in 2015. Prices there rose by 22% in 2015, compared to 12% for London as a whole.
The different methodology of the most popular house price measures is explained here.
Spain's Dani Pedrosa claimed the 50th Grand Prix win of his career with victory over championship leader Valentino Rossi in the Japanese MotoGP.
[NEXT_CONCEPT]
UK house prices rose by 9.5% in 2015, according to the lender Halifax, making it the fastest annual increase in nine years.