Williams started against Belarusian world number 100 Aliaksandra Sasnovich with heavy strapping on her right thigh and then slipped in the fifth game.
The 39-year-old went down again in the seventh game and then retired after struggling to get to her feet.
"I'm so sad for Serena. She is a great champion," said Sasnovich.
"It happens sometimes in tennis, but all the best to her."
Williams, seeded sixth, seemed to do the damage when she rocked backwards on the baseline before unleashing a forehand back to her opponent.
After going off court for treatment, she returned with a heavy limp and tried to continue before it soon became apparent she would be unable to.
Tears filled her eyes as Williams thanked the crowd, who had been trying to encourage her, for their support.
The retirement came less than an hour after Centre Court watched France's Adrian Mannarino also have to retire from his match against Roger Federer.
The 33-year-old had also slipped on the same baseline, leading to Britain's Andy Murray - who had played there on Monday - tweeting about the surface.