Third seed Stan Wawrinka dropped a set against Thomaz Bellucci in the final match of the night session but recovered to reach round three of the US Open.
The Australian Open champion looked completely in control when he won the first two sets but he was unable to sustain the same level in the third.
Brazilian Bellucci fought back and a decider looked on the cards when, with the time ticking past midnight, he went a break up in the fourth set.
This time it was Wawrinka's turn to fight back and, although Bellucci saved two match points in the 10th game, he was well beaten in the tie-break as the Swiss number two came through 6-3 6-4 3-6 7-6 (7/1).
In the third round Wawrinka will meet Slovenia's Blaz Kavcic, who upset 30th seed Jeremy Chardy 6-2 7-6 (8/6) 6-3.
Lleyton Hewitt was unable to cause another upset at the US Open as he went down in straight sets to sixth seed Tomas Berdych in the first round.
The 2001 champion knocked out Juan Martin del Potro last year and went on to reach the fourth round but he found the power of Berdych too much to handle.
Hewitt led 4-1 in the second set but lost the next five games and Berdych eased to a 6-3 6-4 6-3 victory - his 100th in grand slams.
Seventh seed Grigor Dimitrov began his first grand slam as a top-10 player with an impressive 6-2 7-6 (7/4) 6-2 victory over American Ryan Harrison.
Dimitrov is a dark horse for the title after his exceptional season, highlighted by beating Andy Murray in the quarter-finals of Wimbledon, but this was his first ever win at the US Open.
Eleventh seed Ernests Gulbis beat Frenchman Kenny de Schepper 6-1 6-4 6-2 while 14th seed Marin Cilic had a light workout, with opponent Marcos Baghdatis retiring through injury when trailing 6-3 3-1.
Feliciano Lopez, the 19th seed, was also the beneficiary of a retirement in the fifth set of his clash with Ivan Dodig.
The Croatian had his thigh strapped but decided he could not continue and handed Lopez a 1-6 7-5 2-6 6-4 1-1 victory.
Kevin Anderson, seeded 18th, was staring at a first-round loss when opponent Pablo Cuevas served for the match in the fifth set but he recovered to clinch victory on a deciding tie-break.
There was a painful end to American Steve Johnson's hopes against qualifier Tatsuma Ito.
Johnson was leading by two sets to one and 1-0 in the fourth when a leap for a smash brought on an extreme bout of cramp.
He lay on the court unable to move for a number of minutes, with the umpire having no choice but to penalise him for slow play.
After losing a point and a game he climbed back to his feet and attempted to carry on but every movement made the cramp worse and he eventually retired in tears, although he refused a wheelchair and managed to walk off court.
Wednesday's defeats for Johnson and Harrison mean only three American men have reached the second round - John Isner, Sam Querrey and Tim Smyczek.