Gauff, a finalist in the Spanish capital last year, rallied to beat Sorana Cirstea 4-6 7-5 6-1 on Sunday.
"When I actually threw up on the court, that was like a little bit embarrassing," Gauff said.
"Then after that first game and the second, I was like that took everything out of me."
On Saturday, fourth-ranked Iga Swiatek withdrew due to an unspecified illness while playing her round-of-32 match against American Ann Li.
Gauff said she was determined to carry on her match.
"I'm someone who doesn't like to pull out. I don't like to do that unless I really feel like I have no other options," the American added.
"So the plan was to always just try to finish, even if it ended up with me just playing just to get through it.
"They gave me some pills and that definitely helped. After that, once I felt the feeling of throwing up, then I just felt nauseous and tired. I just didn't want to throw up in the middle of the point, which I almost did at one point."
The third-ranked Gauff recovered from a break down three times before winning the set 7-5 and will next meet No.13 seed Linda Noskova, who progressed after Liudmila Samsonova withdrew before taking the court.
In other results, second seed Elena Rybakina progressed after beating Zheng Qinwen, while Anastasia Potapova, Caty McNally and Karolina Pliskova also won in three sets.
World No.5 Jessica Pegula, though, was beaten in two by Marta Kostyuk.
With AAP.