However, her 28-year-old opponent let her nerves overcome her at the most crucial moment, double faulting on her second match point in the second set.
Gauff came through in the tie break which went back and forth as neither player could take advantage of mini-breaks.
Hercog, who has yet to make the last 16 of a Grand Slam in 11 years of trying, went off for a medical time out at the end of the second set.
However, despite being broken by Gauff early on she broke back only for her serve to falter once again as she served to stay in the match.
Whilst her parents stood to applaud their daughter, Gauff danced a little jig of joy as the umpire called the score at the end of the 2hr 47 minute marathon.
“I’m just super relieved that it’s over, it was a long match,” said Gauff.