Williams raced to a 3-0 lead over two-time major champion Garbine Muguruza in their third-round match before dropping six straight games and the first set, 6-3.
“By the score, it might have looked like I started well, but I was not feeling at all well physically,” Williams said in a statement distributed by tournament officials.
During the changeover between sets, Williams called for a trainer. She went back out and lost the first game of the second set. The match was soon declared over and Williams walked off the court.
“Before the match, I did not feel great and then it just got worse with every second; extreme dizziness and extreme fatigue,” Williams said. “I will focus on getting better and start preparing for Miami.”
Muguruza is the only player to have beaten both Serena and Venus Williams in tournament finals.
“It’s really a weird feeling because I don’t feel like I won the match point and well done, good match,” Muguruza said. “It was just like, ‘Man, we’ll play next time.'”
The Spaniard credited Williams for being “very dominating” from the start of the match.
“I had to adapt a little bit my position in the court, the way I was hitting, and it took me a few games to kind of do it,” Muguruza said. “Once I did it, I felt much more comfortable.”
Williams was playing her first tournament since the Australian Open in late January, when she lost in the quarterfinals.
After a first-round bye in Indian Wells, she beat Victoria Azarenka 7-5, 6-3 on Friday night.
It’s the second time in four years that Williams has withdrawn from the tournament. She returned to the desert in 2015 after a 15-year boycott. That year she reached the semifinals before withdrawing against Simona Halep. She missed 2017 because of pregnancy.
Earlier, Roger Federer beat Peter Gojowczyk 6-1, 7-5 in the second round.
Federer saved six of seven break chances against the German after losing just two points on his serve in the first set.
Federer has reached the final of the desert tournament in his last four appearances, winning two years ago. In all, he owns five titles at Indian Wells. He won his 100th career title in Dubai last week.
Halep, the No. 2 seed, needed nearly two hours to beat qualifier Kateryna Kozlova 7-6 (3), 6-3 in the third round.
Kozlova led 6-5 and was within two points of winning the first set before Halep forced a tiebreaker in their first meeting. Halep dominated the tiebreaker, urged on by a large contingent of Romanian fans at Indian Wells Tennis Garden.
Other seeded men’s winners were: No. 6 Kei Nishikori, No. 10 Marin Cilic, No. 14 Daniil Medvedev, No. 22 Kyle Edmund, No. 25 Diego Schwartzman and No. 32 Guido Pella.
No. 16 Fabio Fognini and No. 20 David Goffin were beaten.
On the women’s side, No. 7 Kiki Bertens and No. 18 Qiang Wang advanced.