Gauff appeared visibly frustrated as she was hindered by four double faults and 17 unforced errors in the opening set.
But as she has done all tournament, the seventh seed showed excellent fighting spirit to become the first woman to reach the singles semi-finals with four three-set wins for 30 years.
When her victory was confirmed, Gauff turned to her team and asked "how?".
"I'm confident in myself and the player that I am, but I know tennis. If I wasn't myself, I would [pick] her to win that game with the style she has on this surface," said Gauff, explaining that reaction.
"But because I am me, I pick myself. I think it was just more so that reaction came from like a third-person point of view, rather than necessarily me in the moment.
After an excellent opening set, Pegula was ultimately punished for failing to take her opportunities early in the second, having forced three break points in her opponent's first two games.
The momentum flipped when Gauff capitalised on a poor game from Pegula, breaking to love and maintaining her composure to battle back from 0-30 down as she served out the set to level the match.
The topsy-turvy nature of the contest continued in the final set, but it was Gauff who was able to raise her level when it mattered.
The 2023 US Open and 2025 French Open champion offered an immediate response to take a 4-3 lead after Pegula had broken back, and celebrated victory on Pegula's serve with a first match point.
The loss means Pegula's wait for a first Grand Slam singles title goes on - and she may be left to rue a missed opportunity.