Gauff, the No. 6 seed, held all of her serves in the opening set and finished the 45-minute session with three aces. Osaka had the first double-fault of the match early in the second set and Gauff took advantage for a 2–1 lead.
Gauff quickly built a double-break lead at 5–1 and led 40–0 before Osaka saved four match points and used her first ace to make it 5–2.
Osaka then broke Gauff for the first time in the match and overcame another 40–0 deficit with five straight points for 5–4.
But Gauff closed it out on her eighth match point with an unreturnable serve.
“The most proud was how I responded mentally,” Gauff said. “I could have easily folded in those couple of double-faults and match points that I lost.”
“But I kept telling myself ‘Another point, another chance’ and then the music kind of helped on the bench. I was trying to sing along to the song to get me out of the match.”
Gauff’s victory evened the series with Osaka at two wins apiece.
“I lost the match today but I feel really confident in who I am,” Osaka said. “I feel like the pressure doesn’t beat me. I am the pressure. I’m really happy with that.”
Gauff will face No. 2 seed Paula Badosa on Friday. Other winners in San Jose were Shelby Rogers and No. 4 seed Aryna Sabalenka.
Rogers beat top-seeded Maria Sakkari 6–1, 6–3 to reach the quarterfinals for the third time this season.
Coming off an opening-round win against 2019 US Open champion Bianca Andreescu, she beat Sakkari, a 2018 finalist and 2019 semifinalist in San Jose, for the third straight time.
Sabalenka came back from trailing 5–3 in the third set to edge Caroline Dolehide 5–7, 6–1, 7–5. Sabalenka overcame 20 double-faults in the match to advance to play No. 7 seed Daria Kasatkina of Russia.
The schedule for Friday in the hard-court U.S. Open tune-up includes Wimbledon finalist Ons Jabeur, who will face Veronika Kudermetova.