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."
At first, neither the announcer nor Williams informed the crowd that she had withdrawn from the tournament. He asked the crowd for a round of applause "for this young lady we love very much" when she came out.
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 told the fans that she wouldn't be playing and he apologized. Williams stopped to sign some autographs on her way off court.
She had played four matches since being warmly welcomed back a week ago Friday, winning three in straight sets. Williams told reporters that 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 2001, ending her boycott that began after she won the title as a 19-year-old and was heavily booed. She was supposed to play Venus in the semis, and Venus withdrew 20 minutes before 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," Serena said Friday. "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."
Williams announced that she had withdrawn on her Instagram account while the first semifinal was in the third set, shortly after tournament officials confirmed it.
The Associated Press contributed to this report.
Serena Williams Withdraws From Indian Wells
Serena Williams discusses the right knee injury that forced her to withdraw from the semifinals at Indian Wells.