The second seed lost the first set and had to take a medical time-out in the second but raised his game to win 3-6, 7-5, 3-6, 7-5, 7-6 (10/4) in a match lasting four hours and 21 minutes.
Nadal, a 22-time Grand Slam champion, will play maverick Australian Nick Kyrgios for a place in Sunday's final.
He admitted he was suffering from an abdominal problem.
"For a lot of moments I was thinking I would not be able to finish the match but the crowd, the energy, thanks for that," said the Spaniard.
"I honestly enjoy a lot playing these kind of matches in front of you guys. I can't thank you enough for the support."
A pumped-up Nadal raced out of the blocks to take a 3-1 lead but then lost five straight games to the 11th seed to lose the first set.
The players swapped breaks in the second set but Nadal was not moving freely and when leading 4-3 he sat down on his chair, shaking his head at his team.
The trainer came on before Nadal left the court for a medical time-out to treat what appeared his injury.
When he returned, Fritz served out to love, with Nadal's movement still looking hampered.
But the Spaniard twice held serve comfortably to lead 6-5 and a backhand volley into the open court sealed the second set, to roars from the crowd.
Nadal, 36, was now moving more freely but the pendulum swung again early in the third set when the two-time Wimbledon winner double-faulted to hand his American opponent a break.
The trainer returned, this time to attend to strapping on his Fritz's left thigh and the American resumed playing, breaking again to take the third set.
There were five breaks in a topsy-turvy fourth set as both players struggled for consistency on their serve but Nadal came out on top to level the match.
The first six games of the deciding set went with serve before Nadal produced a backhand dropshot winner to break after a hard-fought seventh game.
Fritz broke back straight away when Nadal netted with a backhand.
The set went to a tie-break and Nadal seized control, racing into a 9-3 lead and completing the win on his second match point.
Nadal, who has already won the Australian Open and the French Open this year, is halfway to the first calendar Grand Slam by a man since Rod Laver in 1969.
He is also bidding to win his 23rd Grand Slam title and equal Serena Williams in second place on the all-time list for most Grand Slam singles titles. Margaret Court is the leader on 24 titles.