The second-seeded Russian was coming off a tough, three-hour win over British qualifier Heather Watson on Tuesday, while Safarova advanced to the third round on a walkover.
Sharapova coasted through the first set and led 3-0 before Safarova mounted a comeback, breaking Sharapova three times to take a 6-5 lead.
Sharapova broke Safarova in the final game to force a tiebreaker, which she won with an ace after 1 hour, 43 minutes.
"After a long match yesterday I was really happy to win in two sets,'' Sharapova said. "I had a bit of a letdown in the second set but was really happy that I could close it out in the tiebreaker.''
Sharapova will face Sam Stosur in the quarterfinals. The eighth-seeded Australian beat Dominika Cibulkova of Slovakia 6-4, 7-5.
In other matches, Sara Errani of Italy beat Marion Bartoli 3-6, 6-2, 6-2, while Nadia Petrova of Russia beat Petra Martic of Croatia 7-6 (2), 6-7 (1), 6-4.
After struggling in the first set, the sixth-seeded Errani broke Bartoli in the second game of the second set and never looked back.
"It was a tough match on this fast court,'' said Errani, who has won three titles this year. "I didn't start off well but neither did she. She got a little tired in the second set and that's when I started to play better.''
Top-ranked Victoria Azarenka was scheduled to face Roberta Vinci of Italy later Wednesday.