Third seed Lleyton Hewitt teetered on the brink of defeat before finally seeing off Taylor Dent 6-3 3-6 6-7 (2-7) 6-2 7-5 at the US Open.
Hewitt moved into the last 16 after battling for three hours 21 minutes.
There was no sign of the drama to come when Hewitt raced into a 5-0 lead in the first set but Dent banished his nerves and went two sets to one up.
Hewitt looked in control when he broke to lead 4-3 in the decider but let Dent in again before eventually prevailing.
"It was an extremely tough match," admitted Hewitt. "I really had to earn it."
The Australian, the 2001 champion at Flushing Meadows and runner-up to Roger Federer last year, will now face Slovakian Dominik Hrbaty, who edged out Spain's David Ferrer 6-7 (7-9) 7-5 7-5 7-5.
Hewitt is seeded to face Roger Federer in the semi-finals but the third seed said he was trying not to think ahead.
"I can't look too far down the line. Obviously Federer is going to be waiting there, most likely. But you can't look too far ahead of yourself," he said.
"You've seen what happened to Nadal and Roddick, there's no easy matches."
If he does face Federer, Hewitt he will need to eliminate the surprising lapses he suffered against Dent.
With Dent looking tired in a tense fifth set, Hewitt appeared to have made the decisive break to lead 4-3.
But in the next game, the Australian sent down two double faults and a forehand error to surrender his own serve.
At 5-5, Hewitt moved to 0-30 with some stunning play, making three incredible saves before Dent smashed a volley into the net.
The American responded with a double fault and Hewitt soon found himself serving for the match.
Dent staged a magnificent rally to save three match points, and even had a break point, before Hewitt finally secured the win with his eighth ace of the match.