It looked like a lock for Sharapova as she won a routine first set, 6-4, and battled back from 1-4 to take the second set to a tie-break and get herself two match points - one at 6-5, one at 7-6. But Safarova fought them both off and snuck out the tie-break, pushing the match into a deciding third set.
But that deciding third set was all Sharapova - the No.4-seeded Russian broke early and never really looked back, eventually beating the No.26-seeded Czech after two hours and 56 minutes, 64 67(7) 62.
Safarova actually saved six more match points in that 5-2 game in the third set before going down.
"It was one of those days when I had all kinds of opportunities, but she just kept hitting all of these unbelievable shots and winners, especially in that last game," Sharapova said in her on-court interview straight after the match. "I'm just so happy I was able to pull the match out in the end tonight."
Sharapova knew Safarova would be a dangerous opponent going into the match. Not only had she beaten Sharapova before, at Madrid in 2010, but she also had 17 - yes, 17 - Top 10 wins to her name.
Afterwards, Sharapova signed the camera lens with 'That's why I play this game!'
Sharapova was asked in her press conference how it feels to battle through matches like that.
"When you're in that situation you have to think selfishly, because you want to be the one winning the match at the end, obviously," Sharapova commented. "But when you come off the court at the end, it's tough to have only one winner, because both players have given a lot and both want to win so much.
"But I've been there a lot, and at this point in my career, especially after not playing for so long last year, these are the kinds of matches I need. These are the kinds of matches I need to build my strength, where I need to feel my shoulder is holding up and I can hit a serve over 1000 miles an hour.
"So these matches are really important for me right now."