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.