Updated

Reigning champion Serena Williams went the distance in order to win her quarterfinal match, while Maria Sharapova had an easier time reaching the semifinals at the $4 million Madrid Open, a clay- court French Open tune-up.

The world No. 1 Williams barely got past Spanish wild card Anabel Medina Garrigues, 6-3, 0-6, 7-5, in 2 hours, 14 minutes at the Magic Box. Medina Garrigues lost despite recording more service breaks (5-4) than her American counterpart on Friday.

After getting bageled in the second set, Williams fell behind 2-4 in the third, despite jumping out to a 2-0 lead, as Medina Garrigues won 10-of-12 games at one point.

But the American great rallied, breaking the 63rd-ranked Spaniard's serve twice en route to one of her trademark come-from-behind victories.

"It was definitely a battle," Williams said. "I obviously didn't do much in the second set and gave her confidence to play better."

The Wimbledon and U.S. Open champion Williams, who beat Victoria Azarenka in last year's marquee Madrid finale, is now 29-2 this season. She'll meet 2012 French Open runner-up Sara Errani on Saturday. Williams is a perfect 4-0 lifetime against Errani, including a victory in the U.S. Open semifinals last year.

Meanwhile, the second-seeded former No. 1 and reigning French Open titlist Sharapova stayed hot by handling Estonian slugger Kaia Kanepi 6-2, 6-4 on Day 7 in the Spanish capital.

The world No. 2 Sharapova is seeking her second title in two events, having recently run the table in Stuttgart. Her semifinal opponent will be fellow French Open winner and fellow former world No. 1 Ana Ivanovic.

Williams and Sharapova could clash in a blockbuster final here on Sunday.

A 16th-seeded Ivanovic upended sixth-seeded German Angelique Kerber 6-3, 6-1, while the aforementioned Italian Errani, seeded seventh this week, reached the semis by tackling Russian Ekaterina Makarova 6-4, 6-3.

Ivanovic will meet Sharapova for a ninth time, seeking a third victory. The Russian beat the Serb in the 2008 Australian Open final and in a quarterfinal in Stuttgart just two weeks ago.