It was Bautista Agut's first win in seven matches against a top 10 player, and del Potro's fourth second-round exit in eight years at the season's first major.
The match lasted 3 hours and 53 minutes and ended at 1:20 a.m. Friday after a long day of match suspensions and delays due to extreme heat and storms.
"I think he played a great match over nearly four hours," del Potro said. "But in every (important) moment ... he played an unbelievable shot. In break-point down, he served well. He made winners with forehands, backhands, and he played always down the line very often."
Bautista Agut had only ever played two five-set matches, losing both, and is now into the third round of a Grand Slam tournament for the first time.
Del Potro won his 18th career singles title last week by beating Bernard Tomic in the final of the Sydney International, a key warm-up event for the Australian Open, and was considered the leading contender from outside the "Big Four" for the Australian title.
"The season has just started," del Potro, the 2009 U.S. Open champion, said. "I will try to be positive for the rest of the year."