Maria Sharapova was made to work hard on her seasonal clay-court debut before eventually seeing off Lucie Safarova in the WTA Porsche Grand Prix.
The top seed and the reigning champion, Sharapova eventually triumphed 6-4 6-7 (3-7) 6-3 after three hours and nine minutes on court in Stuttgart to book her place in the quarter-finals.
The Russian waited until her fifth match point to finally get the better of Safarova. Her next opponent will be Ana Ivanovic, who defeated Nadia Petrova 6-4 6-3 in the second round.
"I've had a few three hour games in my career, so I knew I just had to keep fighting until the end," Sharapova said afterwards. "That's when it's the time to get the game-plan going and calm down a little bit."
Meanwhile, China's Li Na breezed into the last eight after defeating Mirjana Lucic-Baroni in her first match of the clay-court season.
The second seed eased through 6-1, 6-2 against the Croatian in just 74 minutes before admitting she had one eye on the winner's prize - a brand-new Porsche sports car.
The Australian Open runner-up said: "I have a lot of room in my garage for a new car and it's a pretty nice car," joked Li.
"It's always tough when you change surface, so I'm excited to win my first match on clay for the season. Mirjana plays flat, so I had to prepare for that.
"I thought it would be a tough match because she has a lot of experience. I was happy I could play more aggressive and had the right game plan to win."
Li next faces former Wimbledon champion Petra Kvitova, who beat Germany's Julia Goerges 2-6, 7-6(7/4), 6-2 in her second round match.
Third-seed Angelique Kerber also had no problems as she blasted past Russia's Anastasia Pavlyuchenkova 6-0, 6-4 to set up a quarter-final clash with Kazakhstan's 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 the 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.