sister Venus did the same thing and triggered an angry reaction from fans that drove Serena to boycott the tournament.
The world's top-ranked player was to play third-seeded Simona Halep in the second semifinal. Williams addressed the crowd on-court after Jelena Jankovic defeated Sabine Lisicki 3-6, 6-3, 6-1 to reach the final.
"A couple days ago at practice I really injured my knee," Williams told fans. "Today I was struggling just to even walk."
After Williams' brief comments in which she didn't clarify she had withdrawn, fans applauded with only a few boos. As she walked off, the announcer said she wouldn't be playing and he apologized. Williams stopped to sign some autographs on her way out.
She played four matches since being warmly welcomed back a week ago Friday, winning three in straight sets. Williams told reporters she first noticed the injury when she was serving on the practice court and felt a "super sharp" pain in her knee. She said she got an injection for the first time in her career, but it didn't help.
"I have a tremendous amount of inflammation in my knee and it's going to go away. Unfortunately I just need a couple of days," she said. "That's the most frustrating part."
Williams was back for the first time since ending her boycott that began after she won the title in 2001 as a 19-year-old and was heavily booed. She was supposed to play Venus in the semis, and Venus withdrew 20 minutes beforehand with a knee injury, angering the crowd.
Serena went on to beat Kim Clijsters in the final, but fans booed her throughout the match and she vowed never to return to the desert. The sisters' father, Richard, later said he heard racial taunts and there was speculation at the time that he decided in advance which sister would win their matches against each other.
"I feel that was 14 years ago and this is now. I did the best that I could at this event, and I really am happy to have put a lot of that behind me," she said. "If I would have known I had to pull out, I would have played anyway just to have an opportunity to be back at this tournament and to be able to play."Williams called returning to Indian Wells next year "a must."
She said she wasn't nervous facing the crowd after withdrawing.
"I think both myself and the crowd have a great appreciation for each other," she said.
Williams' status for next week's tournament in Miami, where she lives and is the defending champion, is uncertain.
Halep advanced to Sunday's final in a walkover.
"It's really tough for her that she had to withdraw," she said about Williams. "I know how it is when you are injured. It's dangerous and you have to take care of yourself."
Roger Federer defeated Tomas Berdych 6-4, 6-0 and Milos Raonic outlasted Rafael Nadal 4-6, 7-6 (10), 7-5 in a nearly three-hour marathon to set up a semifinal showdown.
Federer improved to 15-1 this year, with his only loss coming against Andreas Seppi in the third round of the Australian Open. Federer avenged that defeat in the same round at Indian Wells. He earned his first straight-set win over Berdych since 2011 in Paris and just his second 6-0 set ever in 19 career matches against the Czech.
Federer needed just 68 minutes to advance to the semis against the sixth-seeded Raonic.
Top-ranked Novak Djokovic takes on fourth-seeded Andy Murray in the other men's semifinal Saturday.
Federer had 21 winners, equaling the number of unforced errors by Berdych. Federer won 13 of 14 points at the net, never faced a break point on his serve, and broke Berdych four times in the match, including three times in the second set.
Raonic beat three-time Indian Wells champion Nadal for the first time in six career meetings, firing 18 aces and hitting 48 winners to 25 winners for Nadal, who had 22 unforced errors.
"It's really great what I was able to do today and I'm very happy with it, but I don't let myself get caught up because this isn't where it ends," Raonic said. "There is a lot more that I want to achieve this week."
They dueled in the second-set tiebreaker, when Nadal held three match points but he committed errors on two of them and Raonic smashed a winner on the other.
Raonic had plenty of chances in the tiebreaker, too, finally converting on his fifth set point when Nadal netted a shot.
Neither gave an inch in the third, staying on serve until the 11th game.
That's when Raonic earned the only break of the set, hitting a shot on the baseline that Nadal chased down but sent a backhand long. Raonic dropped just one point on his serve in the final game, winning on another backhand error by Nadal, who lost to a Canadian player for the first time in nine career matches.