Williams, seeded eighth, suffered the injury in the middle of the second set against Petra Martic but managed to finish out the 6-3, 6-4 victory in 1 hour, 32 minutes.
"I just rolled it. I don't know why," Williams said of the injury that left her cross-legged in the middle of Arthur Ashe Stadium for a few moments. "I was volleying and it just went over, so that was a little frustrating."
She immediately asked for a trainer, who added tape to her lower right leg and foot during a medical timeout at the ensuing changeover. Soon enough, Williams was back on course to make her 11th straight quarterfinals appearance at Flushing Meadows.
"It's been a rough year with injuries,'' said the 37-year-old Williams, who owns six US Open titles, "so I thought, 'Oh, no, not again!'"
The scene Sunday brought back memories of Williams' Australian Open quarterfinal in January against Karolina Pliskova. In that match, Williams was way ahead -- holding a match point at 5-1, 40-30 in the third set -- when she turned her left ankle awkwardly. From there, Williams was no longer, well, Williams, dropping every point she served the rest of the way.
She failed to convert four match points in all that day, ceded six games in a row and lost 7-5 in the third. That time, Williams didn't call for a trainer, which surprised many. She didn't make that mistake this time.
Martic thought Williams' play might actually have improved the rest of the way after her medical timeout.
"She started going for even more, I think. She felt like maybe she couldn't move that well anymore,'' Martic said. "Her shots were really precise. Serve was unbelievable. And when she hits those backhands and those first serves that well, it's not easy to play against her.''
Williams ended things by raising both arms after smacking an ace at 118 mph, her fastest of the afternoon, punctuating an overpowering performance that included 38 winners to Martic's 11.
"I didn't know what to expect from her ball. I knew she [hits it] hard,'' Martic said, "but until you feel it on your own racket, you just don't know what to expect.''
"I can't afford to look at it that way. Every single match I have played, people come and they play their best," Williams said. "The women that I play are not generally playing at this level against other players in the locker room, so for me, I have to be the greatest, whether it's against the second seed, the No. 1 seed or the No. 80th player in the world.
"I have to show up, or else I'm going to go home.''
Williams' win Sunday came on the second birthday of her daughter, Alexis Olympia Ohanian Jr., which Williams noted on Instagram earlier in the day.
A winner of 23 Grand Slam titles, Williams is looking for her elusive first tournament win of any kind since stepping away from tennis in 2017 for the birth of her daughter.
Information from The Associated Press was used in this report.