Frenchwoman Garcia's serve was clicking early and she never faced a break point in the opening set on Tuesday (AEDT), before Gauff raised her level to even the affair at a set apiece.
In the first game of the deciding set, Garcia fended off four break points to hold serve, then broke at love to take a 2-0 lead she would not relinquish against her 20-year-old American opponent.
"I think I stayed positive and optimistic about my serve," Garcia said about the five break points she saved.
"The first game of the third set was quite important for me and maybe for her also, and I got a little bit lucky because my forehand was catching the line, but also I went for it, so maybe it's my reward."
Next up for Garcia is American Danielle Collins, who beat Sorana Cirstea 6-3 6-2.
Rybakina dispatched Florida resident Keys and will next meet a well-rested Maria Sakkari after the Greek eighth seed got a walkover into the quarter-finals.
Elena Rybakina blasts a backhand during her straight-sets win over American Madison Key in Miami. (AP PHOTO)
Rybakina was more efficient than Keys, winning more than 80 per cent of her first-serve points and converting three of her eight break opportunities during the 84-minute encounter.
"Really happy with my performance today," Kazakhstan's Rybakina said.
"It was a tough one. With Madison it's always difficult matches and she's an aggressive player.
"I knew that I needed to be ready for every point, especially on the return."
Rybakina, who due to illness withdrew before her first match at the recent Indian Wells tournament - where she was defending champion - moves into the eighth quarter-final in her past 10 WTA 100 events.
Another player from Kazakhstan, Yulia Putintseva, beat Ukraine's Anhelina Kalinina 6-4 7-6 (7-5).
Sakkari, the eighth seed in Miami, advanced without hitting a ball after Russia's Anna Kalinskaya withdrew ahead of their fourth-round match with health issues.
Kalinskaya, the 22nd seed, arrived in Miami following a third-round defeat at Indian Wells, where a stomach ailment forced her to miss a few days of practice.
The 25-year-old reached the round of 16 in Miami without dropping a set in wins over China's Wang Xiyu and Latvian ninth seed Jelena Ostapenko.
"I'm so sorry I was really looking forward to playing today, but unfortunately my health doesn't allow me," Kalinskaya said.
Rybakina owns a 2-1 record in head-to-head meetings with Sakkari, who arrived in Miami fresh off her loss to world No.1 Iga Swiatek in the Indian Wells final.