The top seed claimed the first set but Czech Lucie Safarova was not backing down and took the second on a tie break.
However she could not maintain her momentum and Sharapova took a routine third to win the match 6-4 6-7 (3/7) 6-3.
She will face Ana Ivanovic next after the former world number one dispatched of Nadia Petrova 6-4 6-3.
The Serb was broken three times but the eighth seed surrendered her serve on five occasions to crash out.
Second seed Li Na made serene progress as she beat Croatian qualifier Mirjana Lucic-Baroni 6-1 6-2 and she meets Petra Kvitova in the last eight.
Kvitova was broken three times as she lost the first set but won the second on a tie break before easing to a 2-6 7-6 (7/4) 6-2 win over Julia Goerges.
Angelique Kerber made short work of Anastasia Pavlyuchenkova as she won 6-0 6-4 in less than an hour and she will next face Yaroslava Shvedova who beat Carla Suarez Navarro 7-5 6-4.
Sabine Lisicki is also into the quarter-finals after she beat Jelena Jankovic in a hard-fought encounter.
Jankovic pushed the German all the way but eventually Lisicki's serve proved decisive as she sent down 11 aces, winning 70% of points on her first serve in a 7-6 (7/3) 7-5 victory.
In Thursday night's final game, which finished well after 1.30am local time, qualifier Bethanie Mattek-Sands stunned fourth seed Sara Errani 6-0 4-6 6-1.