World number 165 Zhang, playing in the tournament on a wildcard, beat the world number 14 and fifth seed 6-4 3-6 6-4.
In a match of few chances, it was the Chinese player who edged a few crucial points, saving one of the three break points that Gasquet earned, and converting all three of the break points he himself earned.
The victory was all the more incredible given Gasquet's superb recent form: the Frenchman finished runner-up in the recent Toronto Masters, and won his tournament last week in Thailand.
"I had chances to win this match and I made bad mistakes," admitted Gasquet, who led 2-0 in the final set.
"He's talented. He plays aggressive and fast, and at the end he played better than me. I didn't play my best match, but it happens and it's because he's talented. He deserves this victory."
Zhang will go on to face Germany's Florian Mayer in the quarter-finals.
Russia's Mikhail Youzhny also progressed to the last eight with an impressive 6-3 6-3 victory over South Africa's Kevin Anderson.
Spain’s Feliciano Lopez denied Chinese Taipei’s Yen-Hsun Lu his first quarter-final berth since June as he fired 10 aces in a 6-5 7-6 triumph. He will meet Sam Querrey who defeated Andreas Seppi 6-1 6-4