Williams, a 23-time Grand Slam champion, was seeded 10th as she continues to work her way back up the rankings after taking time off to have a baby.
Williams won the first three games of the match but called for the trainer after losing six straight to the Spaniard.
After a long talk with the trainer, she took the court for the second set, but called it a day after Muguruza held in the opening game.
Williams and Muguruza were meeting for the sixth time. The previous two clashes came in Grand Slam finals, with Williams winning at Wimbledon in 2015 and Muguruza walking off with the 2016 French Open crown.
“We’ve played many times and it’s always super tough, super exciting,” said Muguruza, currently ranked 20th in the world. “I wish I’m going to see her soon and feeling better.”
Muguruza next faces either Britain’s Johanna Konta or seventh-seeded Kiki Bertens of the Netherlands.