The 14th-seeded Italian will now play world number one Rafael Nadal in the last eight of the tournament.
The first set was even throughout, with both players winning at least two points in all but one game, but there was not a break point until Bautista-Agut won the 10th game to claim the opener 6-4.
Fognini went ahead early in the third, and after briefly being pegged back, he earned a second straight break to move ahead 3-2, and held his lead until winning the set following a hard-fought ninth game.
The scores went to deuce on three occasions before Fognini took the second of his two set points to level the match after an hour-and-a-half, and he took this momentum into the crucial third set.
He broke Bautista-Agut in the second game of the decider, and the Spaniard had no answer as Fognini gave him little hope of a comeback, dropping only four points on serve on his way to clinching victory.