French Open champion Sharapova finished the match with an ace but double-faults on big points almost cost the Russian the second set as the sun set over Tokyo.
"After a long match yesterday, I was just happy to win in two (sets)," said Sharapova, who had taken more than three hours to dispatch British qualifier Heather Watson the previous day.
"Obviously, I had a bit of a let-down in the second set," added the second seed, almost forced into a decider having blown a 3-0 advantage in the set before digging in to claim the tie-break 7-5.
Sharapova will next face eighth seed Samantha Stosur of Australia after last year's US Open champion beat Slovakia's Dominika Cibulkova 6-4 7-5.
"I expect a really tough match," said Olympic silver medallist Sharapova, twice a Pan Pacific Open winner, who served 14 double-faults in her opener and six against Safarova.
"Hopefully I'll play better tomorrow."
World number one Victoria Azarenka recovered from a bout of dizziness to beat Italy's Roberta Vinci 6-4 6-2
Azarenka had her blood pressure checked during the changeover after going 4-3 down in the first set but somehow dug in to take it after Vinci dumped a forehand into the net.
"I felt dizzy on court and my head was spinning between points," said the Belarusian. "I was just trying to finish the points as quickly as possible."
Azarenka, who won this year's Australian Open and reached the US Open final earlier this month, found her feet again to race to a 4-0 lead in the second set.
Still looking flushed between points, Azarenka offered her opponent a glimmer of hope by dropping the next two games before slamming the door firmly shut.
A sliced backhand brought business to a quick conclusion, although Azarenka was still grimacing as she shook hands with Vinci and waved to the crowd.
"I arrived a few days before the tournament and really struggled with my health," said Azarenka. "I've been trying to save my energy for my matches."
"I don't know what exactly it is. Hopefully I'll know as soon as possible and get rid of it. I was pretty lucky. I don't know how I got through really."
Italy's Sara Errani ended the French resistance in Tokyo, overcoming ninth seed Marion Bartoli 3-6 6-2 6-2 to reach the last eight of the WTA premier five event.
The sixth seed won in two hours and 22 minutes, clinching victory with a crunching forehand her opponent could only dump into the net.
"I'm a bit tired but I have lots of motivation to keep winning," said Errani, who has captured titles in Acapulco, Barcelona, Budapest and Palermo this year.
"It's been an amazing year but I still have to qualify for the (season-ending) Championships."
Errani set up a quarter-final against Russia's Nadia Petrova, the 17th seed battling to a 7-6 6-7 6-4 victory over Croatia's Petra Martic.
Seventh seed Li Na, one of three Chinese players to travel to Tokyo despite escalating political tensions between China and Japan, was beaten 4-6 6-3 6-4 by Denmark's Caroline Wozniacki.
Former world number one Wozniacki next faces defending champion Agnieszka Radwanska, the third seed, who progressed with a 6-4 6-3 win over American qualifier Jamie Hampton.
Fifth seed Angelique Kerber played party pooper for the Radwanska family, however, overpowering Agnieszka's younger sister Urszula 6-1 6-1. Azarenka awaits the German.
Nine of the world's top 10 women are competing at the hard court event, with US Open champion Serena Williams the only absentee among the WTA's elite.