World number one Djokovic had to come from a set down to beat a free-spirited Denis Istomin under the centre court lights.
The Serbian was out of sorts at the beginning of his second match as Istomin went for his shots and found the lines with some scintillating tennis.
Djokovic, however, recovered and produced some of his own magic in the second set before he celebrated a hard fought 2-6 6-4 6-4 victory by thrilling the late night crowd with another dancing routine on the centre court, this time wearing a 1970s styled wig.
Djokovic's quarter-final opponent will be French number one Richard Gasquet, who similarly staged a comeback to send Japan's Kei Nishikori home.
Nadal, back in action for the first time since Wimbledon, was given a tough workout by Poland's Jerzy Janowicz but survived to win 7-6 6-4.
Janowicz served for the set and led 3-0 in the second but was unable to capitalise on his chances.
"It was a very good victory against a very difficult opponent," Nadal said.
"He played a little up and down but I'm pleased with the way I played ... It's a great victory for me."
Nadal's next opponent is Australian qualifier Marinko Matosevic, who celebrated his 28th birthday with a 7-6(7) 6-7(10) 6-3 victory over Benoit Paire of France.
Canada's challenge in the tournament reached heights not seen by the locals in over 20 years when 11th seed Milos Raonic joined his 71st ranked compatriot, wildcard Vasek Pospisil, in the last eight.
Raonic ended Juan Martin Del Potro's impressive recent run with a 7-5 6-4 victory while Pospisil chalked up his first ever win over a top 10 player when he held his nerve in a thrilling deciding tiebreak to shock Czech fifth seed Tomas Berdych.
Pospisil had already beaten in-form American John Isner and another Czech in Radek Stepanek to reach the third round.
He will meet another experienced campaigner, Russia's resurgent former world number three Nikolay Davydenko, in his debut Masters series quarter-final.
Montreal Masters results
1-Novak Djokovic (Serbia) beat Denis Istomin (Uzbekistan) 2-6 6-4 6-4
7-Richard Gasquet (France) beat 9-Kei Nishikori (Japan) 1-6 6-3 6-3
11-Milos Raonic (Canada) beat 6-Juan Martin Del Potro (Argentina) 7-5 6-4
Nikolay Davydenko (Russia) beat Alex Bogomolov Jr (Russia) 6-4 6-3
Vasek Pospisil (Canada) beat 5-Tomas Berdych (Czech Republic) 7-5 2-6 7-6(5)
Ernests Gulbis (Latvia) beat 2-Andy Murray (Britain) 6-4 6-3
Marinko Matosevic (Australia) beat Benoit Paire (France) 7-6(7) 6-7(10) 6-3
4-Rafael Nadal (Spain) beat 15-Jerzy Janowicz (Poland) 7-6(6) 6-4