Nadal lost from two sets up against Stefanos Tsitsipas at the same stage last year and it appeared the same may well happen when Shapovalov forced a decider on Rod Laver Arena.
But Nadal, who had called the trainer for a stomach issue during the fourth set, made his experience count to move ahead early in the fifth and hold on for a 6-3 6-4 4-6 3-6 6-3 victory.
A relieved Nadal said: “I was completely destroyed. Very tough day, very warm. I didn’t practise for it.
“I was a little bit lucky at the beginning of the fifth. At the beginning of the match I was playing great but I know how difficult it is to play against a player like Denis.
“For me it’s amazing to be in the semi-finals.”
Importantly, the 35-year-old now has two days off to try to recover physically before his semi-final against either Matteo Berrettini or Gael Monfils.
“I started to feel not very well in my stomach,” said the sixth seed. “I think I was lucky that I was serving great in the fifth. It was a great test and I really believe I’m going to be ready for that semi-final.”
Nadal was not considered among the big favourites at the start of the fortnight having not competed for half of last season because of a foot problem.
But he played himself into that position, dropping only one set to Karen Khachanov during the first four rounds and raising hopes that he could win a record 21st grand slam title.
Shapovalov pulled off one of the biggest victories of his career over third seed Alexander Zverev in the fourth round to reach his third slam quarter-final and first in Melbourne.
The 22-year-old was unable to find his best form in the opening set, though, and then showed his frustration by getting into a row with umpire Carlos Bernardes over the time Nadal was taking between points.
After Bernardes refused to give Nadal a time violation for delaying Shapovalov on his serve, the Canadian shouted: “You guys are all corrupt,” and he and Nadal then had words at the net.
It did not distract Nadal, who moved into a two-set lead, but Shapovalov began to turn the tide in the third set and clinched it with a backhand winner after his opponent was given a time violation.
Nadal began to look weary and troubled in the fourth set, leaving the court for six and a half minutes at the end of it for a medical examination and a toilet break.
Two double faults – he served 11 during the match – put him in trouble in the opening game of the decider but Shapovalov could not take advantage and then dropped serve himself to give Nadal a lifeline.
The Spaniard seized it, finding more conviction in his shots again and exploiting costly errors from his opponent, who will feel he had the match in his grasp.
When a final backhand volley drifted wide, Shapovalov smashed his racket angrily on the court while Nadal celebrated reaching his 36th grand slam semi-final.
Register for free to continue reading
Registration is a free and easy way to support our truly independent journalism
By registering, you will also enjoy limited access to Premium articles, exclusive newsletters, commenting, and virtual events with our leading journalists
Already have an account? sign in
Join our new commenting forum
Join thought-provoking conversations, follow other Independent readers and see their replies