An ailing Rafael Nadal battled past qualifier Tim Smyczek in five sets to reach the Australian Open third round.
The Spaniard fought back to win 6-2 3-6 6-7 (2-7) 6-3 7-5 and avoid his earliest ever defeat in Melbourne.
Nadal, seeded third, required treatment from the doctor for stomach cramps in the third set and repeatedly doubled over in distress.
The 28-year-old was playing just his 10th match since Wimbledon because of injury and illness in 2014.
"At the end of the first set, I started to feel my body was very bad, very tired," said Nadal. "I was worrying like crazy. Then I was serving for the third and almost threw up. It was a terrible feeling.
"I was close to not continuing because I felt that I was very dizzy.
"I was suffering a lot. Too much. Obviously it's a very positive thing that finally I have the chance to win, but I hope to recover myself."
|BBC tennis correspondent Russell Fuller|
|"Nadal says he feels lucky to have had the chance to finish the match, but he took that chance with immense skill and courage even though there may be repercussions in the days ahead.|
|"For Nadal to start cramping so early suggests illness contributed to the problem, but he can't possibly be expected to be in prime condition after playing so few matches since last year's Wimbledon.|
|"Smyczek was fabulous and his sporting gesture in the final game will be long remembered: he allowed Nadal to retake his first serve when distracted by the crowd, despite being only two points from defeat at the time."|
Hampered by his physical issues, the usually miserly Nadal made 53 unforced errors over the course of four hours and 12 minutes on a humid evening in Melbourne.
The 2009 champion had arrived in Australia playing down his chances of winning the tournament, but few expected him to struggle against his unheralded American opponent.
The world number 112 from Milwaukee came through qualifying and had only once before reached the third round of a Grand Slam.
His previous best performance was a victory over world number 19 Jurgen Melzer in Delray Beach three years ago - a far cry from facing Nadal at a Slam.
However, it was the Smyczek forehand and not Nadal's fearsome topspin on that wing that proved the key shot for much of the contest.
The American recovered from losing the first set to break three times in the second, and Nadal looked in trouble early in the third when he called for the doctor, complaining of dizziness and stomach cramps.
|Before their match Tim Smyczek had played in less Grand Slam matches - 13 - than Grand Slam titles won by Rafael Nadal - 14.|
|Nadal has now won 711 matches in his career; Smyczek has 23 professional victories.|
|Nadal has won 17 five-set matches; Smyczek has only played four, winning two.|
The 14-time Grand Slam champion somehow managed to work his way to the brink of the set but failed spectacularly to serve it out, double faulting on break point.
Smyczek raced through the tie-break and an earliest ever Melbourne defeat loomed large for Nadal, who repeatedly slumped over behind the baseline in obvious discomfort.
Dark looks were exchanged with his family and supporters in the stands, and it took some loose play from Smyczek to bring Nadal back into the contest with a break midway through the fourth.
With 16 five-set wins to just two for Smyczek, there was not much doubt that Nadal had the benefit of experience on his side going into the decider.
The Spaniard saw three break points slip by, with Smyczek remarkably calm given the situation, but brilliant backhand and forehand strikes helped Nadal to the decisive break in game 11.
A generous let from Smyczek and three missed match points ensured drama until the very end, but a relieved Nadal sank to his knees after sealing victory at the fourth attempt.