Sharapova looked far from her best throughout the match as she struggled to impose herself on the 21-year-old Gavrilova.
The opening set saw both players broken twice, with Sharpova fighting back from 5-3 down to force a tiebreak. It was Gavrilova who held her nerve in the tiebreaker, taking the breaker 7-2 and with it the set.
Sharapova's troubles continued in the second set, winning just ten points on her own serve as she was broken twice by Gavrilova. The second seed grabbed a break of her own, but could not mount a comeback after falling 3-0 behind and lost the second set 6-3.
Caroline Wozniacki had no such troubles, dispatching of Madison Brengle 6-0, 6-1 in just under an hour.
World number eight Agnieszka Radwanska had a tougher time in her match against Anna Schmiedlova, but managed to come out on top 6-4, 7-5.
Hometown hero Venus Williams also booked her spot in the third round with a 6-3, 6-2 victory over Poland's Urszula Radwanska.