World No.1 Nadal downed Italian Fabio Fognini 6-3 6-1 while second ranked Federer downed Alexandr Dolgopolov 6-4 6-2.
"I have a tough match against Grigor and know I will have to play my best. but I am playing well".
The 16-times grand slam victor, who beat Dimitrov in three sets in the China Open semi-finals last week, fired 32 winners and won two crucial breaks to prevail in two and a half hours at the Qi Zhong Centre. I made bad decision going for the forehand in the 4-2 of the tie-break.
"And then, two good serves for him, 5-4", the 31-year-old world no.1 Nadal said.
Sixth seed Dimitrov frequently had the final say during pulsating rallies, most impressively during the final set when he kept a point alive before winning it close to the net.
Dimitrov extended the quarter-final to a third set when he rebounded from a 4-2 deficit to win the second-set tiebreaker.
Nadal, who is chasing his fourth end of year No.1 ranking, said he was happy to have taken care of his opponent in just over an hour.
In the third set, Nadal saved the one break point he faced in the match in the fifth game, and broke serve in the sixth to set up victory. "I think both of us, we played at a very high level of tennis".
Wimbledon runner-up Marin Cilic also eased into the quarter-finals with a 7-6 (7-1) 6-4 defeat of American Steve Johnson.
Cilic advanced to his first Shanghai semi-final by beating Albert Ramos-Vinolas of Spain 6-3 6-4.