Williams converted on her fourth match point to beat the 96th-ranked Muguruza in 2 hours, 12 minutes on hard court at the southern Brazilian city of Florianopolis.
The American had squandered three match points at 5-4 after getting back on serve late in the third set, but finally closed out the match with her first break point of the final game.
The 20th-ranked Williams is the top-seeded player in Brazil. She is playing her first tournament since losing to Maria Sharapova in the third round of the Australian Open in January.
Williams will now play fifth-seeded Magdalena Rybarikova of Slovakia, who defeated qualifier Beatriz Garcia Vidagany of Spain 6-4, 3-6, 6-4. The 52nd-ranked Rybarikova saved 13 of the 21 break opportunities she conceded in the match that lasted 2 hours, 33 minutes.
Earlier Wednesday, Timea Babos of Hungary beat fourth-seeded Chanelle Scheepers of South Africa 6-1, 6-2. The 133rd-ranked Babos broke Scheepers' serve five times. Scheepers, ranked 60th in the world, had eight break points but converted only one of them.
Babos will play Monica Niculescu of Romania, who easily beat defeated Tereza Mrdeza of Croatia 6-1, 6-1.
Olga Puchkova of Russia continued her remarkable run with a 3-6, 6-3, 6-3 win over Caroline Garcia of France.
Puchkova will play the quarterfinals against Jana Cepelova of Slovakia, who beat eighth-seeded Annika Beck of Germany 7-6 (6), 6-4.
Melinda Czink of Hungary, who eliminated second-seeded and 34th-ranked Yaroslava Shvedova of Kazakhstan in the first round, defeated Brazilian Bia Haddad Maia 1-6, 6-2, 7-6 (3) to set up a quarterfinal match against Frenchwoman Kristina Mladenovic, who cruised past Tatjana Malek of Germany 6-2, 6-1.