Federer stressed it was always going to be hard for the six-time Australian victor to impress on his return from injury, which is why the 36-year-old was not surprised following Djokovic's struggle in Indian Wells.
Returning Monday to finish things off; the Swiss star saved a set point and eventually took the second set tie break 8-6.
The 21-year-old Zimbabwe Davis Cup team player, who is the younger brother of professional tennis player Benjamin Lock, later spoke of his delight at rubbing shoulders with the successful trio in an interview with Standardsport.
Israeli Dudi Sela beat British 21st-seeded Briton Kyle Edmund 6-4 6-4 while Luxemburg's 24th seed Giles Muller was upset by Frenchman Pierre-Hugues Herbert 6-3 7-5.
Djokovic's performance in the final set against the world's 109th-ranked player on centre court raised some eyebrows, with four-times grand slam champion Jim Courier saying the Serb had "capitulated".
After losing to Hyeon Chung in the fourth round of the Australian Open, Djokovic took some time to get himself healthy.
Djokovic said he felt like it was his "first match" on tour and was unable to explain his opening set stumble or his capitulation in the decider. The world No. 44 served only one double fault on her way to wrapping up the match in 1 hour, 21 minutes.
Federer, who finished off Federico Delbonis in a rain-disrupted match to reach the third round, said he understands how even a champion like Djokovic could be struggling to find his game so soon after having surgery.
"Very weird - I just completely lost rhythm", Djokovic said.
"I think I came out playing a little more aggressive than the other two sets and that made him keep making more mistakes".
"But it's not easy to deal with this kind of frustrations after injuries or when you always be the favorite to win a tournament, you come here and you lose in first round".
Federer will face Serbia's Filip Krajinovic, a finalist at the Paris Masters in 2017, in the third round. It is still early stages for Novak coming back and the first one after surgery.
Frenchman Gael Monfils survived a match point before beating big-serving American John Isner 6-7 (5-7), 7-6 (7-3), 7-5 in a contest that had only one break.
The win sets up a third round showdown with Spaniard David Ferrer who defeated Tennys Sandgren of the USA 6-2, 7-6 (7/3).
Spanish veterans David Ferrer and Feliciano Lopez recorded routine straight-sets wins over Tennys Sandgren and Ernesto Escobedo respectively while Philipp Kohlschreiber outlasted Tim Smyczek.