The American was out of sorts on her way to losing the opening set, with 18 unforced errors, and she looked to be heading out of the tournament when she fell 3-0 behind to her Slovakian opponent in the second.
But Williams pulled out all of the stops to turn things around, with an improved serve and better returns eventually resulting in a 2-6 6-4 6-2 victory.
"Mentally I was just struggling," Williams said afterwards on www.wtatennis.com.
"I was playing a really good opponent and I was making so many unforced errors out there - I couldn't pull myself together.
"But the crowd was great. They started saying, 'Come on Serena,' and someone over there kept telling me to relax and I listened, and I also saw my dad on the sideline and he was sitting there looking so calm and relaxed.
"I took all of that energy from the crowd and my dad and I knew I could do better."
Williams' quarter-final opponent will be fifth seed Na Li, who saw off Spanish wild card Garbine Muguruza 7-6 (8/6) 6-2.
Third seed Maria Sharapova had a considerably more comfortable outing as she beat Klara Zakopalova 6-2 6-2.
Fourth seed Agnieszka Radwanska beat 16th seed Sloane Stephens 4-6 6-2 6-0 in one hour and 39 minutes and eighth seed Sara Errani also came from a set down, beating Ana Ivanovic 1-6 6-4 6-2.
Belgium's Kirsten Flipkens, seeded 30th in Miami, also advanced to the last eight with a come-from-behind 6-7 (6/8) 6-4 6-3 victory over Ajla Tomljanovic of Croatia.
There were also wins for Roberta Vinci and Jelena Jankovic.