Nicolas Almagro needed over three hours and five sets to book his place in the next round of the Australian Open.
The Spaniard was twice pegged back by America's Steve Johnson, who eventually ran out of steam in the deciding set.
The number 10 seed found the 23-year-old in inspired form and saw 13 clean winners whizz past his racquet during the first set alone.
However, it was Almagro who made the decisive breakthrough before sealing the first set 7-5.
Johnson continued to frustrate Almagro in the second set, but crucially with more success. It went to a tie-break, with Johnson prevailing 7-4 to level the score.
The third set was a non-event as the experienced Almagro cruised to a 6-2 victory. Johnson struggled with his first-serve percentage and made 14 unforced errors.
Almagro now looked in control, but there was more to come from the American, ranked 175 in the world, in the fourth set.
It went to a tie-breaker, where Almagro had two match points for a place in the second round. He was denied by the dogged Johnson, who hung on to set up a fifth and final set.
It was there where his challenge ended, with Almagro cruising to a 6-2 victory in just over 30 minutes.