Top-ranked Serena Williams outlasted Anabel Medina Garrigues 6-3, 0-6, 7-5 to reach the Madrid Open semifinals on Friday.
Williams appeared to wear down against the scrappy Spaniard on the red clay court, and after getting blanked in the second set she fell behind 4-2 in the decider.
But the defending champion rallied back to break Medina Garrigues' serve twice to move on.
"It was definitely a battle," Williams said.
"I obviously didn't do much in the second set and gave her confidence to play better."
"I just wasn't really into it, my feet weren't moving"
Williams will play Maria Sharapova in the semis after the Russian defeated Kaia Kanepi 6-2, 6-4.
Williams' entertaining match against an opponent she had rightly described as a 'grinder' the day before took several momentum swings.
The 63rd-ranked Medina Garrigues has 10 career clay-court titles - the most of any active player - and her footwork and hustle against Williams showed why.
Williams was ahead 2-0 in the third set and with two break chances to take firm control of the match, but Medina Garrigues ran off four straight points to hold serve and soon enough the upset looked to be in the works.
But Williams regained command of her groundstrokes and a deep drive forced Medina Garrigues into erring her return to cede her serve.
The American favourite then used another powerful shot to break Medina Garrigues again before holding serve to love to close out the match.
Williams said she was still at a loss as to why she lost concentration in that second set, which she considered 'a reference for what not to do.'
"I just wasn't really into it, my feet weren't moving,'' she said.
"To change it I got up early (before the third set) and did some high knees, some stretching, anything I could to get my intensity back up to where it needs to be."
Williams improved her record to 29 wins and two losses on the year.