World No 1 Rafael Nadal ran into a spot of bother before crushing Argentine Leonardo Mayer and booked his place in the last 16 of the US Open with a 6-7(3), 6-3, 6-1, 6-4 victory on Saturday.
The Spaniard, chasing his second grand slam title of the year, was on the back foot early on but once he found his rhythm, the contest was virtually over under a closed roof on Arthur Ashe Stadium.
Nadal will next face Ukraine's Alexandr Dolgopolov.
"It was a tough situation for a set and I had some break points against me early in the second. I fought, I was there mentally and then I started to play much better," said Nadal.
"I must improve on the forehand. At the end of the match I was creating more space but at the beginning I failed to convert several chances with my forehand."
Mayer played some steely tennis in the first set, hitting neat and powerful shots to stave off six break points and force a tiebreak, in which the Argentine was always in control.
In the tiebreak, he took a mini-break for 3-2 when Nadal inexplicably netted a routine backhand and then sealed it with an unreturnable serve.
Nadal was hanging by his teeth, facing two break points in the fourth game of the second set. Two massive shots saved him and he got to level for 2-2 as he let out a huge 'Vamos', raising his clenched fist towards the crowd.
The match was dragging along and while the 23,000 day session spectators enjoyed the match, there were 23,000 waiting outside in the rain for the night session to start.
Nadal played tighter to finally take the first break of the match and move 3-2 up when his opponent sent a forehand wide.
The Spaniard went on to win seven successive points to set up three set points and on the third, he levelled the contest with a jaw-dropping dipping passing shot.
Normal service had resumed as Nadal won his seventh successive game to open up a 3-0 lead in the third set.
Mayer briefly threatened a comeback when he pulled a break back for 5-3 in the fourth set but Nadal served it out at 5-4 with Mayer sending a forehand long on match point.