A limping Djokovic looked to be heading for a shock defeat when 2-1 down in sets and 4-2 behind in the fourth set, but battled back from the brink to delight the Court Philippe Chatrier crowd by winning 6-1, 5-7, 3-6, 7-5, 6-3 after four hours and 39 minutes.
"Three or four times I was points away from losing this match," the reigning champion said to the spectators. "I'm not sure how I won this match."
Djokovic narrowly avoided his earliest exit from the tournament since 2009, teeing up either a rematch of last year's final against Casper Ruud or a clash with Taylor Fritz.
The 24-time Grand Slam title winner had reached the last 16 by defeating Italy's Lorenzo Musetti in another bruising five-set encounter which concluded at 3:07 a.m. Sunday.
He appeared to be feeling no ill-effects as he dominated the first set, but then needed a medical time-out early in the second after pulling up with an apparent knee injury.
The 37-year-old, eyeing a record 370th Grand Slam match win to break out of a tie with Roger Federer, played on but continued to walk gingerly between points.
Cerundolo grabbed the second set by finally taking a break point after 12 previous misses.
The 23rd seed moved ahead by two sets to one against an increasingly frustrated top seed, who was complaining the court was too slippery, before edging to the cusp of a famous win by forging 4-2 in front in the fourth.
But, seemingly from nowhere, Djokovic dug deep to break and level at 4-4.
He forced a decider on his fourth set point of a dramatic 12th game when a stretching Cerundolo could only find the net.
There appeared to be only one outcome on the cards when the Serbian star took a 2-0 advantage in the fifth, but his opponent rallied to level.
Djokovic was left covered in clay after a nasty tumble, sarcastically saying: "Well done supervisors, ground staff, everyone, the court is not slippery at all."
But he was not to be denied, grabbing the decisive break with a blistering forehand that clipped the back of the baseline.
A dramatic triumph and yet another quarter-final was secured on his first match point when a Cerundolo backhand was given out by the chair umpire after initially being ruled in.