But Barty immediately took the next point to be up 4-1 after the Russian overhit her return of the Australian’s second serve.
The world No.2 then won a crucial breakpoint with her well-timed drop shot bringing Sharapova up to the net, before she exquisitely lobbed the ball back inside the flat-footed Russian’s baseline to make it 5-1.
The 23-year-old wasted no time getting into position to serve out for the win, again sealing the set with her second serve.
Barty, who had a bye in the first round, avoided a consecutive opening defeat at a WTA event after she was beaten 6-7 (5-7), 6-3, 6-4 by American Sofia Kenin at last week’s Canadian Open.
In fact, the win is the Australian’s 40th of the season, with her win-loss record 40-7, leaving her second only to Dutch ace Kiki Bertens (41-16).
It was also Barty’s second victory over Sharapova this year after her fourth-round win in the Australian Open in January.
Barty will face either Pole Iga Swiatek or Estonian Anett Kontaveit in the following round.
In other matches, Simona Halep rallied after dropping the first set to defeat Ekaterina Alexandrova 3-6, 7-5, 6-4.
The Wimbledon champion fought off two break points in the eighth game of the third set and then broke Alexandrova to serve for the match.
Elina Svitolina, a Wimbledon semi-finalist, easily reached the third round with a 6-4, 6-1 win over Elise Mertens.