The Spanish world number three, returning from injury, was taken to the brink by American qualifier Tim Smyczek before winning a tough five-setter when he looked down for the count.
The 14-time Grand Slam champion prevailed 6-2, 3-6, 6-7 (2/7), 6-3, 7-5 in 4hr 12min and will now play unseeded Israeli Dudi Sela in the third round.
Nadal, who lost to Stan Wawrinka in last year's Melbourne final, said he was suffering from stomach cramps during the thriller as he used all his experience to get himself over the line on Rod Laver Arena.
"It was a very tough night for me," said Nadal.
"For me after a tough period of time out of competition in the last seven months and just playing a few matches, today was a little bit humid and I felt very tired after the first set and for the whole match."
Swiss Grand Slam master Federer was stung into action after losing the first set to reel in Italian Simone Bolelli in four sets and take his place in the seeded round.
Murray, a three-time runner-up in Melbourne, extended his record against Australian opponents to 10-0 with a consummate straight sets victory over Marinko Matosevic.
Elsewhere, 10th seed Grigor Dimitrov overcame Lukas Lacko in four sets and seventh seed Tomas Berdych accounted for Jurgen Melzer.
Second seed Federer, chasing his fifth Australian Open title, problem-solved his way to a 3-6, 6-3, 6-2, 6-2 win over Bolelli and will play another Italian Andreas Seppi in the third round.
The 17-time Swiss Grand Slam champion, who developed a mystery swollen finger during the contest, lost the opening set after the only break on his serve, but he found a solution and swept through the next three sets.
"It's always a good feeling fighting your way out of a match, winning the last three sets convincingly and actually playing really positive tennis," said Federer.
"Today I had to do some adjustments because he was doing things very well. By figuring things out it's a great feeling to have once you've got it."
The Swiss legend was non-plussed by a swollen finger that may have been caused by a bee sting.
"It's the weirdest thing. I don't know. I feel it on the tip of my finger. I feel like it's numb and swollen," he said.
Murray got some payback on vocal local hope Matosevic, with the British sixth seed having few problems in winning 6-1, 6-3, 6-2. He will next face Portugal's Joao Sousa.
It was some riposte for Murray after Matosevic criticised the surprise appointment of Amelie Mauresmo as his coach last year.
Matosevic created headlines back then when he dismissively said of Murray's decision to replace Ivan Lendl with Mauresmo: "I couldn't do it because I don't think that highly of the women's game."
Bulgaria's Dimitrov reached the third round after downing Lacko 6-3, 6-7 (10/12), 6-3, 6-3 and will now play former finalist Marcos Baghdatis.
Rising Australian younger Nick Kyrgios also advanced with a four-set win over big-serving Ivo Karlovic, while Sam Groth knocked out fellow Australian Thanasi Kokkinakis in five sets.
Groth will now take on another young Australian Bernard Tomic, who squeezed home in four sets against German Philipp Kohlschreiber.
Like Sports on Facebook, follow @ETribuneSports on Twitter to stay informed and join in the conversation.
COMMENTS
Comments are moderated and generally will be posted if they are on-topic and not abusive.
For more information, please see our Comments FAQ