Osaka only herself reclaimed top spot by reaching the last eight at the Rogers Cup, but defeat to Sofia Kenin at the same stage in Cincinnati would open the door for Barty.
The Japanese, having battled back after losing the first set, taking the second 6-1, was forced to retire at the WTA Premier event on Saturday (AEST).
Osaka had required treatment to a knee injury and finally retired after being broken early in the third set.
Barty will now unseat Osaka if she advances to the final, having reached the last four with a stunning comeback victory over Maria Sakkari 5-7 6-2 6-0.
Meanwhile, Karolina Pliskova's own hopes of reaching the summit, a possibility if Barty also fell by the wayside, ended as she crashed out to Svetlana Kuznetsova in another three-set contest.
The ranking might be on the line for Barty, but she is happy to set that aside and focus on going as far as possible in Cincinnati.
"I'm just keeping my eye on the ball and, if I win matches, the ranking will take care of itself," she said after her win.
"We're excited to be in new territory here in Cincy."
Kuznetsova awaits the Australian and French Open champion.
It was not a good day for reigning US Open champion Osaka.
Osaka retired with a leg injury against Kenin, handing Barty the chance to return to the WTA summit.
It also means Osaka is under an injury cloud ahead of the US Open at Flushing Meadows, where she stunned Serena Williams last year.
"It sucks, especially since I didn't want to get injured this close to the Open," Osaka said. "And now I'm kind of worried a little bit.
"She was playing well. I had to really think about what I had to do during the match, so I'm not that mad at the result. The injured part sucks, but losing, it's not that big of a deal."
Two-time grand slam champion Kuznetsova outlasted No.3 seed Pliskova 3-6 7-6 (7-2) 6-3 to reach the final four.
Kuznetsova was down a set with Pliskova serving for the match but the Russian rallied thanks to 30 winners and six aces in the gruelling two hour, 23-minute clash.
Meanwhile, Madison Keys vanquished seven-time major champion Venus Williams 6-2 6-3 to set up a semi-final with fellow American Kenin.