The defending champion cut an angst-ridden figure for long periods of a tense clash at London's O2 Arena.
Despite having a spiritual guru in his camp these days, Djokovic has been anything but serene lately and once again the defending champion cut an angst-ridden figure for long periods of a tense clash in the prestigious season-ending event at London's O2 Arena.
Djokovic had reacted furiously after being grilled by the media about a potentially dangerous incident when he slammed a ball into the stands during his win against Dominic Thiem on Sunday.
This time, the world number two grumbled over camera flashes from the crowd and held a finger to his lips to urge them to be quiet, while moaning when Raonic tried some gamesmanship by taking his time tying up his shoelaces at a key moment in the first set tie-break.
But, to his credit, Djokovic handled everything a fired-up Raonic threw at him to ensure he remains on course to win the Tour Finals for a fifth successive year and record-equalling sixth time in total.
The 29-year-old, who has now won 20 of his last 21 matches at the Tour Finals, would also regain the number one ranking from Andy Murray if he leaves south London with the silverware.
"I managed to hang in there mentally and stay strong and believed that the opportunities would come and that I could take them," Djokovic said.
"Milos was hanging in there and only one or two points separated us in the second set.
"It could have gone either way this match. He's such a strong player and has got firepower."
With Austria's Thiem having kept alive his hopes of reaching the semi-finals with a 6-3, 1-6, 6-4 victory over Gael Monfils earlier on Tuesday, Djokovic knew a win would seal his last four berth with one match still to play.
Djokovic had won all seven of his previous encounters with Raonic, dropping only one set in the process, but he had his hands full with the powerful Canadian this time.
Wimbledon finalist Raonic, who defeated Monfils in his opening match, earned break points in the Serb's first two service games, but Djokovic wriggled out of trouble on both occasions and the set went to a tie-break.
Despite serving eight aces and hitting more than three times as many winners as Djokovic, Raonic just couldn't kill him off and in the breaker an ill-timed double fault on set point gifted the first set to the Serb.
It had taken Djokovic 64 minutes to move ahead and the 12-time Grand Slam champion wasn't going to let that effort go to waste.
He broke in the first game of the second set and recovered from dropping serve three games later to hit back with another break for a 3-2 lead.
Just as the finish line was in sight, Djokovic was broken again in the eighth game and he had to save a set point at 5-6 to force another tie-break.
Djokovic was pushed hard in the breaker, but he had the answer on every big point and eventually wrapped up a gutsy victory in two hours and 14 minutes.
Tour Finals debutant Thiem could join Djokovic in the last four after seeing off flamboyant Frenchman Monfils.
The 23-year-old will need to defeat Raonic in his last group match on Thursday to reach the semi-finals.
Monfils is now certain to be eliminated after losing his first two matches.
"It was a very close match but luckily he helped me in the last game. Maybe I was the lucky one today," Thiem said.
"I am very happy there's still a chance for me to reach the semi-finals, but Milos Raonic is an amazing opponent."