Six-times champion Djokovic blasted the 22nd seed off the court in the opening set but Bautista Agut grew more aggressive in the second, stepping in to take his second serves early and baiting his opponent into extended rallies.
The tide turned in Bautista Agut's favour in the third when, after both players exchanged service breaks, an uncharacteristically sloppy Djokovic sent a backhand wide to fall behind 4-2.
Three games later Bautista Agut smacked a forehand winner down the line to seal the win, which was reminiscent of Bautista Agut's come-from-behind victory over Djokovic in the semi-finals of the Qatar Open in January.
The loss capped a disappointing trip through the U.S. for Djokovic, who fell in straight sets to Philipp Kohlschreiber in the third round of the BNP Paribas Open in Indian Wells earlier this month.
Next up for Bautista Agut is a quarter-final date with defending champion John Isner, who was a 7-6(5) 7-6(3) winner over Britain's Kyle Edmund earlier in the day.
Nick Kyrgios continued to mix the obscene with the sublime as he bowed out of the tournament at the hands of Borna Coric.
The Australian produced perhaps the shot of the tournament early in his 4-6 6-3 6-2 loss to the 11th seed but was given a point penalty for an audible obscenity apparently directed at a spectator that put him down a double break in the third.
Kyrgios has made headlines all week in Miami for his controversial underhanded serves, a verbal spat with a spectator who was heckling him, and for firing off an expletive-laden rant at an umpire during a doubles match.