Novak Djokovic survived a nervous start to see off Sam Querrey 7-5 6-1 at the Cincinnati Masters on Tuesday.
Seven-time Cincinnati champion Federer, also playing his first match since Wimbledon, was quicker to get back in the groove, needing just 61 minutes to dispatch Juan Londero 6-3 6-4 in their night match, which was halted in the second set due to rain.
Defending champion Djokovic fired his 15th ace on match point to defeat Querrey but his serve had been an issue earlier in their second-round encounter.
“I made three double faults in my opening game and lost the break. I was quite a nervous at the start,” he said after falling behind 2-0 to the American.
“I’m really glad to overcome a challenge like this and get myself going.”
Djokovic, who defeated Federer in a classic five-set battle at Wimbledon in July, said he had needed time to recover from the mental strain of that match.
“That was one of the most epic matches I’ve been a part of and probably the most demanding one from the mental perspective,” he said.
“So it really did take me some time to recharge my batteries, especially in my head. My body was fine.”
Djokovic will face either John Isner or Pablo Carreno Busta in the next round, with a potential quarter-final meeting with Australian Nick Kyrgios.
Federer will take on Swiss compatriot Stan Wawrinka or Andrey Rublev in the third round.