* Russian Sharapova edges second seed Li Na of China
* Top seed Williams pulls out before Kvitova match (Adds Sharapova quotes, later results)
MADRID May 9 (Reuters) - Maria Sharapova fought back from to oust China's Li Na 2-6 7-6(5) 6-3 and claim a place in the last four of the Madrid Open on Friday as top seed and defending champion Serena Williams withdrew with a thigh problem.
Russian Sharapova, the eighth seed, showed all her battling qualities on the clay at the futuristic Magic Box arena to edge the world number two and set up a semi-final clash with third-seeded Pole Agnieszka Radwanska or French qualifier Caroline Garcia.
"The match was very close, I think it really could have gone her way today," Sharapova told a news conference.
"It was just a matter of a few points in the second set," added the former world number one.
"Although I was up a break throughout the third set, you know, she's not going to let go. I didn't win the match until the last point was played."
Sharapova had beaten Li in four of their last five encounters, including twice on clay, and she said experience had helped her through.
"It's a combination of experience and kind of what you teach yourself and the motivation that you find inside of yourself to not get down when you're feeling things aren't going the exact way that you wanted them to," added the 27-year-old.
"I didn't play a great first set and I found a way to get myself in a position to be in the third.
"Then certainly something changed a little bit and I did something different to get myself going and give myself a bit more energy than I had in the first set."
Sharapova lost to top-ranked American Serena Williams in the 2013 Madrid final and her chances of going one better this year were boosted when Williams withdrew with a thigh injury before her quarter-final against Czech fifth seed Petra Kvitova.
Williams, winner of the last two editions of the tournament and seeking her 60th career singles title, suffered the injury in her first-round match against Belinda Bencic.
With the French Open just two weeks away she decided to pull out to give herself time to recover.
"It's beyond words. It's so frustrating," Williams said in comments released by the WTA. "This is not the way I wanted this week to end."
The 17-times grand slam singles champion had been on a run of 15 consecutive victories in the Spanish capital and her victory over Carla Suarez Navarro in the last round brought up her 650th win on the women's tour.
In Friday's other quarter-final, fourth seed Simona Halep of Romania cruised past 11th-seeded Serb Ana Ivanovic, another former world number one, 6-2 6-2 and will play Kvitova for a place in Sunday's final. (Reporting by Iain Rogers, editing by Ed Osmond)