Williams started against Aliaksandra Sasnovich with heavy strapping on her thigh and slipped in the fifth game.
The 39-year-old went down again in the seventh game and was overcome by emotion before having to retire.
Centre Court gave a standing ovation as she left, with Williams later saying: “The court meant the world to me.” 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, the seven-time champion 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.