Reigning US and Australian Open champion Osaka needed more than two hours to outlast Aliaksandra Sasnovich 7-6 (7/3), 2-6, 6-2.
The Japanese star will next face a third-round match against Taiwan’s Hsieh Su-Wei, who defeated American Jennifer Brady 7-6 (11/9) 6-3.
Osaka finally scored a win here at the US Open warm-up after losing in the first round a year ago.
She had eight aces, 24 winners and breaks on four of five chances against an opponent who was treated on her right knee several times.
Australia’s Barty, 23, won the battle of former number one players in just over 90 minutes. The reigning Roland Garros champion beat five-time Grand Slam winner Sharapova, who was Cincinnati champion in 2011, for the second time this season.
It was Barty’s 40th victory of 2019 and she next faces Estonia’s Anett Kontaveit, who beat Polish teenager Iga Swiatek 6-4, 7-6 (7/2).
Barty fired 18 winners, breaking Sharapova four times as the Russian made 31 unforced errors.
Fourth-seeded Halep took a late break in the penultimate game of the final set to beat Russian Ekaterina Alexandrova 3-6, 7-5, 6-4 after two hours on court.
The Romanian has finished runner-up in Cincinnati three times, last reaching the final a year ago against Kiki Bertens.
In the next round, the 27-year-old, who retired injured from her Toronto quarter-final against Czech qualifier Marie Bouzkova last week, will face American Madison Keys, a 6-4, 6-1 winner over Russia’s Daria Kasatkina.
World number three Karolina Pliskova beat China’s Wang Yafan 6-1, 6-3, while seventh seed Elina Svitolina, a semi-finalist four years ago, advanced past Belgian Elise Mertens 6-4, 6-1.
In the men’s draw, fifth seed Stefanos Tsitsipas saved three match points but still lost to Germany’s Jan-Lennard Struff 6-4, 6-7 (5/7), 7-6 (8/6).
Kei Nishikori went out to fellow Japanese Yoshihito Nishioka 7-6 (7/2), 6-4. Sixth seed Nishikori has still never advanced beyond the third round in Cincinnati.
Alexander Zverev, seeded seventh, remained winless in his Cincinnati career after losing 6-7 (4/7), 6-2, 6-4 to 19-year-old Serb Miomir Kecmanovic. The German struck an unbelievable 20 double-faults in defeat.
Ninth seed Daniil Medvedev, losing finalist to Rafael Nadal in Montreal last weekend, eased past Benoit Paire 7-6 (7/2), 6-1 and will next face Struff.
France’s Richard Gasquet, who ended Andy Murray’s comeback singles tournament in the first round, saw off Argentinian Federico Delbonis 7-5, 7-6 (7/1).
Australian Alex de Minaur defeated American Reilly Opelka 7-6 (7/3), 6-4 to set up a third-round tie with Nishioka. (AFP)