France’s Garcia staged a strong fightback to prevail 3-6 7-6(6) 6-4 in two hours and 44 minutes for her first victory over the former world number one in her fifth attempt.
Sharapova, who came back from a 15-month doping ban at this tournament last April, won the first set with ease but the 31-year-old could not prevent a determined Garcia from dragging herself back into the contest through a tiebreak.
A 10th double fault by Sharapova at 4-4 handed Garcia the crucial break in the decider and the world number seven clinched the contest on her serve in the next game.
Up next for Garcia is Ukrainian teenager Marta Kostyuk who beat Antonia Lottner 6-4 6-1. The 15-year-old qualified for the main draw by overcoming France’s Alize Cornet on Monday.
World number six Karolina Pliskova also advanced with a 6-2 6-2 win over Kiki Bertens while Magdalena Rybarikova dumped out Russia’s Daria Kasatkina 6-2 6-2.