MADRID—Two-time defending champion Serena Williams withdrew from the Madrid Open on Friday because of a left thigh injury.

The top-ranked American has had her thigh heavily bandaged during play at the clay-court event, and said the injury occurred during a first-round victory over Belinda Bencic on Sunday.

"It started to get better but, most importantly right now, I just need some time to rest and recover. It's beyond words. It's so frustrating," Williams said in a statement. "This is not the way I wanted this week to end."

The withdrawal gave 2011 champion Petra Kvitova a walkover victory and a spot in the semifinals.

The 32-year-old Williams said the injury would not keep her out of the French Open, with the defending champion tweeting she would play in Rome next week before the second Grand Slam of the season starts on May 25.

"Sad I could not play my match today. But I'm recovering fast and getting ready for Rome and Roland Garros," Williams wrote.