The Spaniard defeated Italy's Fabio Fognini 2-6, 6-4, 6-2, 6-1 but only after suffering a bizarre self-inflicted injury when leading 3-0 in the fourth set.
The four-time champion, and holder of a men's record 22 Grand Slam titles, was hurt when his racquet bounced back off the court as he stretched for a ball and hit him squarely on the nose.
The 36-year-old Australian and French Open champion dropped his racquet to the Arthur Ashe Stadium floor and sprinted to the sidelines where he lay on his back with his nose bloodied.
He required a medical timeout to have the wound tended before resuming the match with a bandage across the bridge of his nose.
Nadal goes on to face France's Richard Gasquet against whom he boasts a 17-0 career record after coming through his late night scrap which saw a total of 15 breaks of serve and 97 unforced errors.
Fognini defeated Nadal from two sets down at the US Open in 2015.
Buoyed by that memory, the 35-year-old swept through the first set with breaks in the third and seventh games against a sluggish and error-plagued Nadal.
It was the second successive match in which Nadal had dropped the first set after suffering the same fate in his opener against Australian wildcard Rinky Hijikata.
The first five games of the second set were all breaks with Nadal forced to call the trainer to treat blisters on his left hand at 2-3 down.
Fognini stretched to a 4-2 lead before Nadal reeled off the next four games to take the set and level the tie.
In each of the first two sets, Nadal had managed to hit a meagre three winners.
The four-time champion, however, then doubled his winners count to grab the third set against a suddenly dispirited Fognini who needed a medical timeout to have his right foot bandaged.
Nadal coasted to a 3-0 lead when his bizarre injury temporarily stalled his progress to the last 32.