French Open champion Barty double faulted to give Sharapova a 2-1 lead in the first set and it looked like an upset could be brewing in the showdown between the two former world number ones.
But an error-prone Sharapova bowed out after she produced six double faults and squandered six of her seven break point opportunities.
"Overall it was a pretty clean performance," Barty said.
"It's difficult to come out against a player like Maria. She's an incredible champion, she knows how to fight and she makes you earn every single point.
"So I was really pleased with the way I was able to hang in there today and win some of those big points."
Barty earned an early break in the second set when she rifled a crosscourt forehand that caught Sharapova flat footed for a 2-0 lead.
Sharapova fought hard the next game, forcing seven deuces but was unable to break and Barty cruised to the finish from there, winning 11 of the last 13 games.
Barty will next face Anett Kontaveit, who defeated Polish teenager Iga Swiatek in straight sets.
Wimbledon champion Halep had her back against the wall against the big-serving Alexandrova when she dropped the first set and trailed 5-4 in the second but won the next three games and elevated her play again in the decider.
Fourth seed Halep is searching for her first title at the event after three runner-up finishes in 2015, 2017 and 2018.
"I feel confident every time I come here but the conditions are very tough. The court is very fast," the Romanian said.
Third seeded Karolina Pliskova crushed lucky loser Wang Yafan 6-1 6-3 and Donna Vekic knocked out former champion Victoria Azarenka 6-2 7-5 to set up a showdown with Venus Williams on Thursday.