It looked to be a complete runaway as Muguruza built a 6-0, 5-2 lead and seemed to be well on her way to a convincing victory over the Canadian.
Andreescu fought back to win 11 of the final 12 games to claim a 0-6, 7-6 (3), 6-1 victory that sees her into the second round after two hours, 12 minutes of hard work.
The win meant that the former US Open champion maintained her perfect record against the Spaniard, having now won all three of their encounters.
Story of the match
Muguruza came out of the blocks on fire, hitting eight winners in the first to just two for Andreescu and one of those was on her second break point of the fourth game, a perfectly placed crosscourt backhand into the corner.
That side was working well for the two-time major winner and she forced a forehand error from the Canadian with it to break to love and close out a first set that took just 24 minutes.
After early breaks were exchanged in the second set, Muguruza used her forehand to reclaim the advantage, leaving Andreescu flat-footed as she again found the corner of the court and took a 4-2 lead.
The first real sign of nerves crept in when the former world number one served for the match at 5-3, but was broken and the set would eventually be decided in a tiebreaker.
In the breaker, Muguruza seemed to find her footing again, winning the first two points, but Andreescu won seven of the final eight points, closing out the set with an ace to level the match.
The final set was one-way traffic as the Canadian dominated, breaking Muguruza from 40-15 down to go in front 3-1 and blistering a backhand to make it 5-1.
Serving for the match, Andreescu closed things out on her third match point as Muguruza flew a forehand long and must wonder how she let a huge lead slip away.