Nadal had not dropped a set till the game and was hoping to continue that form ahead of the second week but was thankful to hold on as the game neared completion.
Federer will take on Marton Fucsovics in the fourth round. The unseeded 25-year-old beat Argentine Nicolas Kicker 6-3 6-3 6-2 to earn his spot opposite the all-time great.
Rafael Nadal admits that sweltering conditions can become a "little bit dangerous for health" after temperatures hit 40C on day five of the Australian Open in Melbourne.
Roger Federer tried to have his second round match against Jan Lennard Struff moved to the evening to avoid the searing temperatures at the Australian Open.
Monfils was clearly feeling the conditions after winning the first set and struggled to get a foothold into the game as Djokovic came back to win the game 4-6 6-3 6-1 6-1.
Temperatures at the Australian Open have reached 40 Celsius (104 Fahrenheit) with reports of 69 degrees (156F) being measured on the court surface.
Novak Djokovic made his way into the third round of the Australian Open defeating Frenchman Gael Monfils in four sets 4-6 6-3 6-1 6-3.
World number one Rafael Nadal secured his place in the third round of the 2018 Australian Open on Wednesday thanks to a 6-3 6-4 7-6 (7-4) win over Argentina's Leonardo Mayer.
The nominees for the Laureus World Sports Awards are headlined by Roger Federer and Rafael Nadal, while there is a raft of British interest.
Roger Federer is worried he might not be able to repeat his "fairytale" 2017 triumph despite easing into the second round with a confident straight-sets win over Aljaz Bedene.
Roger Federer is currently defending his Australian Open crown in Melbourne and has no plans to retire from the game in the short-term.
The six-time Australian Open champion cut an emotional figure after the game, embracing the crowd for their support.
Rafael Nadal is refusing to contemplate retirement after coming through his opening match at the Australian Open without alarm.
Novak Djokovic's situation is akin to that of Roger Federer in 2017 when the Swiss ace also came back from a lengthy spell on the sidelines.
Roger Federer had an extremely successful 2017 campaign following the same schedule, going on to win seven titles, including the Australian Open and Wimbledon.