Squaring off for the first time, the Serb claimed the first two sets and looked well on his way to a straight sets victory only to see the teenager rattle off four games in a row to capture the third set.
In the end, Shapovalov made far too many mistakes and went away quietly in the fourth set, finishing with a total of 57 unforced errors on the day as Djokovic booked a spot in the Round of 16 for the 11th time in Melbourne.
Djokovic gifted first set on Shapovalov unforced errors
Nerves showed early as Shapovalov was overhitting on his groundstrokes as he misfired on a forehand to set up a break point for the Serb and totally mishit the return one point later to hand Djokovic the early lead.
The Canadian was in trouble in his next service game as he again faced break point, this time the world number one missing on a backhand to bring the game back to deuce, but on his second chance, Djokovic was ahead 4-1 after Shapovalov missed his own backhand by miles.
The 25th seed did well to get one of the breaks back to close the gap to 4-2 and further reduced the margin to 4-3 with a hold, but serving to stay in the set, he was broken again, dumping a forehand into the net on set point.
Djokovic claims second set on strength of late break
The nerves that seemed to plague Shapovalov seemingly went away as he kept pace with Djokovic for the majority of the set. Both men were brutally efficient on serve, the Serb losing just four points while the Canadian dropped the same amount through nine games.
Another test for the youngster came in the ninth game as he again served to stay in the set. He got himself in trouble with an errant forehand to fall behind 15-30 and faced set point after a backhand slice missed its mark.
Djokovic was two sets ahead after Shapovalov missed on another forehand, the six-time champion seemingly on his way to a straight sets victory.
Shapovalov stuns Serb with third set fightback
The end of the second set seemed to stay with the Canadian early on in the third as he committed two more unforced errors on the forehand wing to set up triple break point for Djokovic. The Serb deftly played a drop shot to which Shapovalov had no reply.
A hold by the world number one had him out to a 3-0 lead and it appeared it was only a matter of time before Djokovic was safely through to the fourth round. In a stunning turn of events, the Serb handed the break back with a game full of errors.
Now level at 4-4, Djokovic gave Shapovalov another opening with a pair of forehand errors to set up two break points. Saving the first, the top seed double-faulted to hand the Canadian the chance to serve for the set.
A 12-point game ensued with Djokovic saving two set points and Shapovalov fending off a break point before the Canadian finally found the mark with a forehand on his third set point to reduce the deficit and force a fourth set.
Djokovic closes out match with shutout in fourth set
Shapovalov reached 30-30 in the opening game of the fourth set but Djokovic was able to hold on and was soon ahead 15-40 on the Canadian's serve. An 18 ball rally ended when the 25th seed badly mishit a backhand to surrender his serve.
A hold to 30 put Djokovic up 3-0 and he soon had a second break of serve after Shapovalov committed three straight unforced errors from 30-15 ahead, the Serb now with a commanding 4-0 lead.
After another hold made it 5-0, Shapovalov served to stay in the match. At deuce, Djokovic fired a backhand winner to set up a match point and he was safely through to the Round of 16 against Daniil Medvedev when the Canadian ended the match with a double fault.