Holding a 3-1 lead in the first set, Williams slipped and needed to take an injury timeout at the game's conclusion to receive treatment. She returned to the court, but her movement was visibly limited.
Williams was serving in the fifth game at Centre Court when she lost her footing near the baseline while hitting a forehand. She winced and stepped gingerly between points, clearly troubled.
After dropping that game, she took a medical timeout and tried to continue playing. A crying Williams bit her upper lip and covered her face between points as the crowd tried to offer support and encouragement. But eventually, the 39-year-old American dropped to her knees, and the chair umpire came over to check on her.
The match ended at 3-all in the first set.
Williams, a seven-time Wimbledon singles champion, gave an emotional wave to the crowd and held her hand over her heart as she fought back tears before she exited the court.
Williams did not speak to the media afterward, though she offered some reaction on Instagram thanking the fans.
"I was heartbroken to have to withdraw today after injuring my right leg," she wrote. "My love and gratitude are with the fans and the team who make being on centre court so meaningful. Feeling the extraordinary warmth and support of the crowd today when I walked on -- and off -- the court meant the world to me."
Williams' coach, Patrick Mouratoglou, said in a text Wednesday morning to ESPN's Chris McKendry: "Apparently the injury is at the top of her hamstring, in the glute."
This marks just the second time in Williams' storied career she has retired from a match at a major. The other occurrence was in the third round at the All England Club in 1998.
"Of course I'm so sad for Serena; she's a great champion," Sasnovich said. "It happens sometimes in tennis, but all the best for her and her recovery."
Williams entered the tournament in search of her 24th major title, which would have tied her with Margaret Court for the most ever. She last won a Grand Slam at the Australian Open in 2017 and has made four finals since returning after giving birth, including at Wimbledon in 2018 and 2019. She made the semifinals at the Australian Open earlier this year as well as the fourth round at the French Open last month.
"Yeah, it was not easy to watch," said Coco Gauff. "Actually I turned away. I was in the gym actually stretching. I turned away because stuff like that makes me ... really emotional.
"I mean, I wish [Serena] the best. I wish that hopefully she can have a speedy recovery. Yeah, you could tell she was really emotional. Nobody ever wants to retire, but especially at a Grand Slam, a place as special as Wimbledon after waiting two years to come back. The only thing I can do is wish her well wishes and hope she'll be back in time for the hard court season."
Williams was the second player on Centre Court on Tuesday to slip and suffer an injury. Adrian Mannarino, who was playing against Roger Federer, also was forced to retire as a result of a similar fall. Due to rain, the roof had been closed.
"I do feel it feels a tad more slippery maybe under the roof," Federer said after his match. "I don't know if it's just a gut feeling. You do have to move very, very carefully out there. If you push too hard in the wrong moments, you do go down.
"This is obviously terrible that it's back-to-back matches and it hits Serena as well. Oh, my God, I can't believe it."
Top-seeded men's player Novak Djokovic fell twice in the first set of his first-round victory Monday in the main stadium, too.
The All England Lawn Tennis & Croquet Club released a statement later in the day, addressing the condition of the courts.
"The preparation of the grass courts has been to exactly the same meticulous standard as in previous years," the statement said. "Each grass court is checked by the Grand Slam Supervisors, Referee's Office and Grounds team ahead of play commencing, and on both days of the Fortnight they have been happy with the conditions and cleared the courts for play.
"The weather conditions on the opening two days have been the wettest we have experienced in almost a decade, which has required the roof to be closed on Centre Court and No.1 Court for long periods. This is at a time when the grass plant is at its most lush and green, which does result in additional moisture on what is a natural surface. With each match that is played, the courts will continue to firm up."
Information from The Associated Press was used in this report.